]> granicus.if.org Git - php/commitdiff
fix possible leak on failure in get_defined_functions()
authorAntony Dovgal <tony2001@php.net>
Wed, 20 Dec 2006 23:19:44 +0000 (23:19 +0000)
committerAntony Dovgal <tony2001@php.net>
Wed, 20 Dec 2006 23:19:44 +0000 (23:19 +0000)
Zend/zend_builtin_functions.c

index a5c8ca1c839a153af24d266166d7c8dbc69669c6..97e9a6368522fd0488189002b8f76a743d0d0ad4 100644 (file)
@@ -1500,11 +1500,16 @@ ZEND_FUNCTION(get_defined_functions)
        zend_hash_apply_with_arguments(EG(function_table), (apply_func_args_t) copy_function_name, 2, internal, user);
 
        if (zend_ascii_hash_add(Z_ARRVAL_P(return_value), "internal", sizeof("internal"), (void **)&internal, sizeof(zval *), NULL) == FAILURE) {
+               zval_ptr_dtor(&internal);
+               zval_ptr_dtor(&user);
+               zval_dtor(return_value);
                zend_error(E_WARNING, "Cannot add internal functions to return value from get_defined_functions()");
                RETURN_FALSE;
        }
 
        if (zend_ascii_hash_add(Z_ARRVAL_P(return_value), "user", sizeof("user"), (void **)&user, sizeof(zval *), NULL) == FAILURE) {
+               zval_ptr_dtor(&user);
+               zval_dtor(return_value);
                zend_error(E_WARNING, "Cannot add user functions to return value from get_defined_functions()");
                RETURN_FALSE;
        }