Skip to content

Commit 98a4c53

Browse files
authored
sapi/apache2handler/php_functions.c: No need to rely on argnum (php#16143)
1 parent acf1a6c commit 98a4c53

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

sapi/apache2handler/php_functions.c

+9-15
Original file line numberDiff line numberDiff line change
@@ -249,22 +249,19 @@ PHP_FUNCTION(apache_setenv)
249249
php_struct *ctx;
250250
char *variable=NULL, *string_val=NULL;
251251
size_t variable_len, string_val_len;
252-
bool walk_to_top = 0;
253-
int arg_count = ZEND_NUM_ARGS();
252+
bool walk_to_top = false;
254253
request_rec *r;
255254

256-
if (zend_parse_parameters(arg_count, "ss|b", &variable, &variable_len, &string_val, &string_val_len, &walk_to_top) == FAILURE) {
255+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|b", &variable, &variable_len, &string_val, &string_val_len, &walk_to_top) == FAILURE) {
257256
RETURN_THROWS();
258257
}
259258

260259
ctx = SG(server_context);
261260

262261
r = ctx->r;
263-
if (arg_count == 3) {
264-
if (walk_to_top) {
265-
while(r->prev) {
266-
r = r->prev;
267-
}
262+
if (walk_to_top) {
263+
while(r->prev) {
264+
r = r->prev;
268265
}
269266
}
270267

@@ -284,22 +281,19 @@ PHP_FUNCTION(apache_getenv)
284281
char *variable;
285282
size_t variable_len;
286283
bool walk_to_top = 0;
287-
int arg_count = ZEND_NUM_ARGS();
288284
char *env_val=NULL;
289285
request_rec *r;
290286

291-
if (zend_parse_parameters(arg_count, "s|b", &variable, &variable_len, &walk_to_top) == FAILURE) {
287+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &variable, &variable_len, &walk_to_top) == FAILURE) {
292288
RETURN_THROWS();
293289
}
294290

295291
ctx = SG(server_context);
296292

297293
r = ctx->r;
298-
if (arg_count == 2) {
299-
if (walk_to_top) {
300-
while(r->prev) {
301-
r = r->prev;
302-
}
294+
if (walk_to_top) {
295+
while(r->prev) {
296+
r = r->prev;
303297
}
304298
}
305299

0 commit comments

Comments
 (0)