Skip to content

Commit

Permalink
sapi/apache2handler/php_functions.c: No need to rely on argnum (php#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
Girgias authored Sep 30, 2024
1 parent acf1a6c commit 98a4c53
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions sapi/apache2handler/php_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,22 +249,19 @@ PHP_FUNCTION(apache_setenv)
php_struct *ctx;
char *variable=NULL, *string_val=NULL;
size_t variable_len, string_val_len;
bool walk_to_top = 0;
int arg_count = ZEND_NUM_ARGS();
bool walk_to_top = false;
request_rec *r;

if (zend_parse_parameters(arg_count, "ss|b", &variable, &variable_len, &string_val, &string_val_len, &walk_to_top) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|b", &variable, &variable_len, &string_val, &string_val_len, &walk_to_top) == FAILURE) {
RETURN_THROWS();
}

ctx = SG(server_context);

r = ctx->r;
if (arg_count == 3) {
if (walk_to_top) {
while(r->prev) {
r = r->prev;
}
if (walk_to_top) {
while(r->prev) {
r = r->prev;
}
}

Expand All @@ -284,22 +281,19 @@ PHP_FUNCTION(apache_getenv)
char *variable;
size_t variable_len;
bool walk_to_top = 0;
int arg_count = ZEND_NUM_ARGS();
char *env_val=NULL;
request_rec *r;

if (zend_parse_parameters(arg_count, "s|b", &variable, &variable_len, &walk_to_top) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &variable, &variable_len, &walk_to_top) == FAILURE) {
RETURN_THROWS();
}

ctx = SG(server_context);

r = ctx->r;
if (arg_count == 2) {
if (walk_to_top) {
while(r->prev) {
r = r->prev;
}
if (walk_to_top) {
while(r->prev) {
r = r->prev;
}
}

Expand Down

0 comments on commit 98a4c53

Please sign in to comment.