fix leak and invalid dtor
[m6w6/ext-http] / php_http_querystring.c
index 67df721b9015729fbbb030d903614ff0f92eef88..84398a3b0d534ece1584caabd5ca65890a53f1af 100644 (file)
@@ -39,6 +39,7 @@ static inline void php_http_querystring_set(zval *instance, zval *params, int fl
 
        php_http_querystring_update(&qa, params, NULL);
        zend_update_property(php_http_querystring_class_entry, instance, ZEND_STRL("queryArray"), &qa);
+       zval_ptr_dtor(&qa);
 }
 
 static inline void php_http_querystring_str(zval *instance, zval *return_value)
@@ -185,8 +186,6 @@ ZEND_RESULT_CODE php_http_querystring_parse(HashTable *ht, const char *str, size
                } while (*asi_str);
 
                opts.param = php_http_params_separator_init(&arr);
-
-               zval_ptr_dtor(&arr);
        }
 
        ZVAL_NULL(&opts.defval);
@@ -344,18 +343,13 @@ PHP_METHOD(HttpQueryString, getGlobalInstance)
        php_http_expect(SUCCESS == zend_parse_parameters_none(), invalid_arg, return);
 
        zs = zend_string_init(ZEND_STRL("instance"), 0);
-       instance = zend_std_get_static_property(php_http_querystring_class_entry, zs, 0, NULL);
+       instance = zend_std_get_static_property(php_http_querystring_class_entry, zs, 0);
        zend_string_release(zs);
 
        if (Z_TYPE_P(instance) != IS_OBJECT) {
                zval *_GET = NULL;
-               zend_string *zs = zend_string_init("_GET", lenof("_GET"), 0);
-
-               zend_is_auto_global(zs);
 
-               if ((_GET = zend_hash_find(&EG(symbol_table).ht, zs))
-               &&      (Z_TYPE_P(_GET) == IS_ARRAY)
-               ) {
+               if ((_GET = php_http_env_get_superglobal(ZEND_STRL("_GET")))) {
                        zval new_instance;
 
                        ZVAL_OBJ(&new_instance, php_http_querystring_object_new(php_http_querystring_class_entry));
@@ -368,8 +362,6 @@ PHP_METHOD(HttpQueryString, getGlobalInstance)
                } else {
                        php_http_throw(unexpected_val, "Could not acquire reference to superglobal GET array", NULL);
                }
-
-               zend_string_release(zs);
        }
 
        RETVAL_ZVAL_FAST(instance);