]> granicus.if.org Git - php/commitdiff
Fixed access to undefined properties
authorDmitry Stogov <dmitry@zend.com>
Fri, 28 Feb 2014 12:56:52 +0000 (16:56 +0400)
committerDmitry Stogov <dmitry@zend.com>
Fri, 28 Feb 2014 12:56:52 +0000 (16:56 +0400)
Zend/zend_object_handlers.c

index 62c8ad41c0f2f16ece2ec83db3b8434370a1f527..4b40fca6444ebebcbc521601893a38a2c794f0e2 100644 (file)
@@ -393,6 +393,7 @@ static long *zend_get_property_guard(zend_object *zobj, zend_property_info *prop
 {
        zend_property_info info;
        zval stub, *guard;
+       zend_string *str = NULL;
 
        if (!property_info) {
                property_info = &info;
@@ -402,7 +403,7 @@ static long *zend_get_property_guard(zend_object *zobj, zend_property_info *prop
                zend_unmangle_property_name(property_info->name->val, property_info->name->len, &class_name, &prop_name);
                if (class_name) {
                        /* use unmangled name for protected properties */
-                       info.name = STR_INIT(prop_name, strlen(prop_name), 0);
+                       str = info.name = STR_INIT(prop_name, strlen(prop_name), 0);
                        property_info = &info;
                }
        }
@@ -410,11 +411,17 @@ static long *zend_get_property_guard(zend_object *zobj, zend_property_info *prop
                ALLOC_HASHTABLE(zobj->guards);
                zend_hash_init(zobj->guards, 0, NULL, NULL, 0);
        } else if ((guard = zend_hash_find(zobj->guards, property_info->name)) != NULL) {
+               if (str) {
+                       STR_RELEASE(str);
+               }
                return &Z_LVAL_P(guard);
        }
 
        ZVAL_LONG(&stub, 0);
        guard = zend_hash_add(zobj->guards, property_info->name, &stub);
+       if (str) {
+               STR_RELEASE(str);
+       }
        return &Z_LVAL_P(guard);
 }
 /* }}} */
@@ -508,6 +515,10 @@ zval *zend_std_read_property(zval *object, zval *member, int type, const zend_li
                                        zend_error(E_ERROR, "Cannot access property started with '\\0'");
                                }
                        }
+                       if (!silent) {
+                               zend_error(E_NOTICE,"Undefined property: %s::$%s", zobj->ce->name->val, Z_STRVAL_P(member));
+                       }
+                       retval = &EG(uninitialized_zval);
                }
        } else {
                if (!silent) {