From: Nikita Popov Date: Wed, 3 Aug 2016 21:09:17 +0000 (+0200) Subject: Fix leak on self-referencing constants X-Git-Tag: php-7.1.0beta3~115 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ec6d70db770874d11f6d76ce31ed9b28e56049a5;p=php Fix leak on self-referencing constants --- diff --git a/Zend/zend_constants.c b/Zend/zend_constants.c index 3e09f0cbb8..1759f8dd07 100644 --- a/Zend/zend_constants.c +++ b/Zend/zend_constants.c @@ -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);