From a8cad398fcd2a1711c37696940ac9141a05ff7fc Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Thu, 13 May 2010 02:13:30 +0000 Subject: [PATCH] - Fixed bug #51791 (constant() aborts execution when fail to check undefined constant) --- NEWS | 2 ++ Zend/tests/bug51791.phpt | 14 ++++++++++++++ ext/standard/basic_functions.c | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 Zend/tests/bug51791.phpt diff --git a/NEWS b/NEWS index ac210bc950..2f82a55399 100644 --- a/NEWS +++ b/NEWS @@ -50,6 +50,8 @@ PHP NEWS requests (Fixes CVE-2010-0397, bug #51288). (Raphael Geissert) - Fixed 64-bit integer overflow in mhash_keygen_s2k(). (Clément LECIGNE, Stas) +- Fixed bug #51791 (constant() aborts execution when fail to check undefined + constant). (Felipe) - Fixed bug #51732 (Fileinfo __construct or open does not work with NULL). (Pierre) - Fixed bug #51725 (xmlrpc_get_type() returns true on invalid dates). (Mike) diff --git a/Zend/tests/bug51791.phpt b/Zend/tests/bug51791.phpt new file mode 100644 index 0000000000..b6ced4bccd --- /dev/null +++ b/Zend/tests/bug51791.phpt @@ -0,0 +1,14 @@ +--TEST-- +Bug #51791 (constant() failed to check undefined constant and php interpreter stoped) +--FILE-- + +--EXPECTF-- +Warning: constant(): Couldn't find constant A::B1 in %s on line %d +NULL diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index e9a6a8bd60..8889337d6c 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -3826,7 +3826,7 @@ PHP_FUNCTION(constant) return; } - if (!zend_get_constant_ex(const_name, const_name_len, return_value, NULL, 0 TSRMLS_CC)) { + if (!zend_get_constant_ex(const_name, const_name_len, return_value, NULL, ZEND_FETCH_CLASS_SILENT TSRMLS_CC)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't find constant %s", const_name); RETURN_NULL(); } -- 2.50.1