]> granicus.if.org Git - php/commitdiff
- Fixed bug #51791 (constant() aborts execution when fail to check undefined constant)
authorFelipe Pena <felipe@php.net>
Thu, 13 May 2010 02:13:30 +0000 (02:13 +0000)
committerFelipe Pena <felipe@php.net>
Thu, 13 May 2010 02:13:30 +0000 (02:13 +0000)
NEWS
Zend/tests/bug51791.phpt [new file with mode: 0644]
ext/standard/basic_functions.c

diff --git a/NEWS b/NEWS
index ac210bc950bf3c26938afe71285f14ffb3ead6b6..2f82a55399db517d1a7040a81f62d3aac7a61bbd 100644 (file)
--- 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 (file)
index 0000000..b6ced4b
--- /dev/null
@@ -0,0 +1,14 @@
+--TEST--
+Bug #51791 (constant() failed to check undefined constant and php interpreter stoped)
+--FILE--
+<?php
+
+class A  {
+    const B = 1;
+}
+var_dump(constant('A::B1'));
+
+?>
+--EXPECTF--
+Warning: constant(): Couldn't find constant A::B1 in %s on line %d
+NULL
index e9a6a8bd60dfa89d500cbbd98a82a29ad5e392e2..8889337d6cc6cc27a552fde4b534c212d4815e1a 100644 (file)
@@ -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();
        }