]> granicus.if.org Git - php/commitdiff
Fixed bug #29015 (Incorrect behavior of member vars(non string ones)-numeric mem...
authorDmitry Stogov <dmitry@php.net>
Thu, 28 Apr 2005 17:39:56 +0000 (17:39 +0000)
committerDmitry Stogov <dmitry@php.net>
Thu, 28 Apr 2005 17:39:56 +0000 (17:39 +0000)
NEWS
Zend/tests/bug29015.phpt [new file with mode: 0644]
Zend/zend_object_handlers.c

diff --git a/NEWS b/NEWS
index f4f26553c6c7ae78c429975185ef136a4d7c86ab..d8922921b38ed375c3b656141f91bfab70912e15 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -68,6 +68,8 @@ PHP                                                                        NEWS
 - Fixed bug #29210 (Function: is_callable - no support for private and
   protected classes). (Dmitry)
 - Fixed bug #29104 (Function declaration in method doesn't work). (Dmitry)
+- Fixed bug #29015 (Incorrect behavior of member vars(non string ones)-numeric
+  mem vars und others). (Dmitry)
 - Fixed bug #28839 (SIGSEGV in interactive mode (php -a)).
   (kameshj at fastmail dot fm)
 
diff --git a/Zend/tests/bug29015.phpt b/Zend/tests/bug29015.phpt
new file mode 100644 (file)
index 0000000..6c18ab8
--- /dev/null
@@ -0,0 +1,11 @@
+--TEST--
+Bug #29015 (Incorrect behavior of member vars(non string ones)-numeric mem vars und others)
+--FILE--
+<?php
+$a = new stdClass();
+$x = "";
+$a->$x = "string('')";
+var_dump($a);
+?>
+--EXPECTF--
+Fatal error: Cannot access empty property in %sbug29015.php on line 4
index 78ea73727338f58b7625c5f3586cac0eb8e78763..508b1f79f154f5e902e5e380b13e0bcdaad6abcd 100644 (file)
@@ -199,6 +199,16 @@ static inline zend_property_info *zend_get_property_info(zend_object *zobj, zval
        zend_property_info *scope_property_info;
        zend_bool denied_access = 0;
 
+       if (Z_STRVAL_P(member)[0] == '\0') {
+               if (!silent) {
+                       if (Z_STRLEN_P(member) == 0) {
+                               zend_error(E_ERROR, "Cannot access empty property");
+                       } else {
+                               zend_error(E_ERROR, "Cannot access property started with '\\0'");
+                       }
+               }
+               return NULL;                            
+       }
        ulong h = zend_get_hash_value(Z_STRVAL_P(member), Z_STRLEN_P(member)+1);
        if (zend_hash_quick_find(&zobj->ce->properties_info, Z_STRVAL_P(member), Z_STRLEN_P(member)+1, h, (void **) &property_info)==SUCCESS) {
                if (zend_verify_property_access(property_info, zobj->ce TSRMLS_CC)) {