Skip to content

Commit cf7624f

Browse files
committed
PCBC-321: Prevent paramparser from segfaulting with non-array options argument.
1 parent 3b71531 commit cf7624f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

paramparser.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,19 @@ int pcbc_pp_begin(int param_count TSRMLS_DC, pcbc_pp_state *state, const char *s
8787
} while(1);
8888

8989
if (param_count < state->arg_req) {
90-
php_printf("Less than required number of args\n");
90+
php_printf("Less than required number of args.\n");
9191
return FAILURE;
9292
}
9393

9494
arg_unnamed = state->arg_req + state->arg_opt;
9595
if (param_count > arg_unnamed) {
9696
znamed = *args[arg_unnamed];
97+
98+
// Ensure that it is an options array!
99+
if (Z_TYPE_P(znamed) != IS_ARRAY) {
100+
php_printf("Options argument must be an associative array.\n");
101+
return FAILURE;
102+
}
97103
} else {
98104
znamed = NULL;
99105
}

0 commit comments

Comments
 (0)