Skip to content

Commit d966821

Browse files
committed
sapi/apache2handler/php_functions.c: No need to rely on argnum
1 parent bfa7285 commit d966821

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

sapi/apache2handler/php_functions.c

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -249,22 +249,20 @@ 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;
252+
bool walk_to_top = false;
253253
int arg_count = ZEND_NUM_ARGS();
254254
request_rec *r;
255255

256-
if (zend_parse_parameters(arg_count, "ss|b", &variable, &variable_len, &string_val, &string_val_len, &walk_to_top) == FAILURE) {
256+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|b", &variable, &variable_len, &string_val, &string_val_len, &walk_to_top) == FAILURE) {
257257
RETURN_THROWS();
258258
}
259259

260260
ctx = SG(server_context);
261261

262262
r = ctx->r;
263-
if (arg_count == 3) {
264-
if (walk_to_top) {
265-
while(r->prev) {
266-
r = r->prev;
267-
}
263+
if (walk_to_top) {
264+
while(r->prev) {
265+
r = r->prev;
268266
}
269267
}
270268

@@ -284,22 +282,19 @@ PHP_FUNCTION(apache_getenv)
284282
char *variable;
285283
size_t variable_len;
286284
bool walk_to_top = 0;
287-
int arg_count = ZEND_NUM_ARGS();
288285
char *env_val=NULL;
289286
request_rec *r;
290287

291-
if (zend_parse_parameters(arg_count, "s|b", &variable, &variable_len, &walk_to_top) == FAILURE) {
288+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &variable, &variable_len, &walk_to_top) == FAILURE) {
292289
RETURN_THROWS();
293290
}
294291

295292
ctx = SG(server_context);
296293

297294
r = ctx->r;
298-
if (arg_count == 2) {
299-
if (walk_to_top) {
300-
while(r->prev) {
301-
r = r->prev;
302-
}
295+
if (walk_to_top) {
296+
while(r->prev) {
297+
r = r->prev;
303298
}
304299
}
305300

0 commit comments

Comments
 (0)