]> granicus.if.org Git - php/commitdiff
Improved parameter parsing
authorIlia Alshanetsky <iliaa@php.net>
Tue, 27 Jan 2009 21:59:30 +0000 (21:59 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Tue, 27 Jan 2009 21:59:30 +0000 (21:59 +0000)
sapi/apache_hooks/php_apache.c

index d0191d2929e85614d8da2bc20dfbce3e8266d43e..0e31ccf1d59768da86d12f00aba513065d117b33 100644 (file)
@@ -222,7 +222,7 @@ static void apache_request_string_slot(int offset, INTERNAL_FUNCTION_PARAMETERS)
 {
        zval *id;
        request_rec *r;
-       char *old_value, *new_value;
+       char *old_value, *new_value = NULL;
        int new_value_len;
        char **target;
 
@@ -235,19 +235,13 @@ static void apache_request_string_slot(int offset, INTERNAL_FUNCTION_PARAMETERS)
        target = (char **)((char*)r + offset);
        old_value = *target;
 
-       switch (ZEND_NUM_ARGS()) {
-               case 0:
-                       break;
-               case 1:
-                       *target = ap_pstrdup(r->pool, new_value);
-                       break;
-               default:
-                       WRONG_PARAM_COUNT;
-                       break;
+       if (new_value) {
+               *target = ap_pstrdup(r->pool, new_value);
        }
 
-       if (old_value)
+       if (old_value) {
                RETURN_STRING(old_value, 1);
+       }
 
        RETURN_EMPTY_STRING();
 }