]> 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:40:11 +0000 (17:40 +0000)
committerDmitry Stogov <dmitry@php.net>
Thu, 28 Apr 2005 17:40:11 +0000 (17:40 +0000)
Zend/tests/bug29015.phpt [new file with mode: 0644]
Zend/zend_object_handlers.c

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 e7ac0a3e78089b672935e44a6ab748741ed0fb44..64c2aa515e164904190d556bbfcb6fed223c6316 100644 (file)
@@ -147,6 +147,16 @@ ZEND_API struct _zend_property_info *zend_get_property_info(zend_class_entry *ce
        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(&ce->properties_info, Z_STRVAL_P(member), Z_STRLEN_P(member)+1, h, (void **) &property_info)==SUCCESS) {
                if (zend_verify_property_access(property_info, ce TSRMLS_CC)) {