]> granicus.if.org Git - php/commitdiff
Fix leak on self-referencing constants
authorNikita Popov <nikic@php.net>
Wed, 3 Aug 2016 21:09:17 +0000 (23:09 +0200)
committerNikita Popov <nikic@php.net>
Wed, 3 Aug 2016 21:10:09 +0000 (23:10 +0200)
Zend/zend_constants.c

index 3e09f0cbb8296a5c859d8bbee163939a581cc7da..1759f8dd071361eba13d78f0aa91ebca182d8a7f 100644 (file)
@@ -375,12 +375,14 @@ ZEND_API zval *zend_get_constant_ex(zend_string *cname, zend_class_entry *scope,
                        if (Z_TYPE_P(ret_constant) == IS_CONSTANT_AST) {
                                if (IS_CONSTANT_VISITED(ret_constant)) {
                                        zend_throw_error(NULL, "Cannot declare self-referencing constant '%s::%s'", ZSTR_VAL(class_name), ZSTR_VAL(constant_name));
+                                       ret_constant = NULL;
                                        goto failure;
                                }
                                MARK_CONSTANT_VISITED(ret_constant);
                        }
                        if (UNEXPECTED(zval_update_constant_ex(ret_constant, ce) != SUCCESS)) {
                                RESET_CONSTANT_VISITED(ret_constant);
+                               ret_constant = NULL;
                                goto failure;
                        }
                        RESET_CONSTANT_VISITED(ret_constant);