]> granicus.if.org Git - php/commitdiff
Fixed bug #48004 (Error handler prevents creation of default object)
authorDmitry Stogov <dmitry@php.net>
Tue, 21 Apr 2009 08:12:07 +0000 (08:12 +0000)
committerDmitry Stogov <dmitry@php.net>
Tue, 21 Apr 2009 08:12:07 +0000 (08:12 +0000)
NEWS
Zend/tests/bug48004.phpt [new file with mode: 0644]
Zend/zend_execute.c

diff --git a/NEWS b/NEWS
index afa651a08dd65087868a53069d312c0580ac97ab..7e4bfa38b8433c5c488949b537bcf424d90e2cba 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,8 @@ PHP                                                                        NEWS
   context. (Dmitry)
 
 - Fixed bug #48023 (spl_autoload_register didn't store closures). (Etienne)
+- Fixed bug #48004 (Error handler prevents creation of default object).
+  (Dmitry)
 - Fixed bug #47880 (crashes in call_user_func_array()). (Dmitry)
 - Fixed bug #47856 (stristr() converts needle to lower-case). (Ilia)
 - Fixed bug #47851 (is_callable throws fatal error). (Dmitry)
diff --git a/Zend/tests/bug48004.phpt b/Zend/tests/bug48004.phpt
new file mode 100644 (file)
index 0000000..5968876
--- /dev/null
@@ -0,0 +1,21 @@
+--TEST--
+Bug #48004 (Error handler prevents creation of default object)
+--FILE--
+<?php
+function error_handler($errno, $errstr, $errfile, $errline, $errcontext) {
+        return true;
+}
+
+function test() {
+        $data->id = 1;
+        print_r($data);
+}
+
+set_error_handler("error_handler");
+test();
+?>
+--EXPECT--
+stdClass Object
+(
+    [id] => 1
+)
index 5fba77a475daa0c043fc8707895c998f5442bd08..fb0e8fcd0b6a94a04e036808a82dc7794575084e 100644 (file)
@@ -518,13 +518,13 @@ static inline int zend_verify_arg_type(zend_function *zf, zend_uint arg_num, zva
 static inline void zend_assign_to_object(znode *result, zval **object_ptr, zval *property_name, znode *value_op, const temp_variable *Ts, int opcode TSRMLS_DC)
 
 {
-       zval *object;
+       zval *object = *object_ptr;
        zend_free_op free_value;
        zval *value = get_zval_ptr(value_op, Ts, &free_value, BP_VAR_R);
        zval **retval = &T(result->u.var).var.ptr;
 
-       if (Z_TYPE_P(*object_ptr) != IS_OBJECT) {
-               if (*object_ptr == EG(error_zval_ptr)) {
+       if (Z_TYPE_P(object) != IS_OBJECT) {
+               if (object == EG(error_zval_ptr)) {
                        if (!RETURN_VALUE_UNUSED(result)) {
                                *retval = EG(uninitialized_zval_ptr);
                                PZVAL_LOCK(*retval);
@@ -532,13 +532,14 @@ static inline void zend_assign_to_object(znode *result, zval **object_ptr, zval
                        FREE_OP(free_value);
                        return;
                }
-               if (Z_TYPE_PP(object_ptr) == IS_NULL ||
-                   (Z_TYPE_PP(object_ptr) == IS_BOOL && Z_LVAL_PP(object_ptr) == 0) ||
-                   (Z_TYPE_PP(object_ptr) == IS_STRING && Z_STRLEN_PP(object_ptr) == 0)) {
-                       zend_error(E_STRICT, "Creating default object from empty value");
+               if (Z_TYPE_P(object) == IS_NULL ||
+                   (Z_TYPE_P(object) == IS_BOOL && Z_LVAL_P(object) == 0) ||
+                   (Z_TYPE_P(object) == IS_STRING && Z_STRLEN_P(object) == 0)) {
                        SEPARATE_ZVAL_IF_NOT_REF(object_ptr);
-                       zval_dtor(*object_ptr);
-                       object_init(*object_ptr);
+                       zval_dtor(object);
+                       object = *object_ptr;
+                       object_init(object);
+                       zend_error(E_STRICT, "Creating default object from empty value");
                } else {
                        zend_error(E_WARNING, "Attempt to assign property of non-object");
                        if (!RETURN_VALUE_UNUSED(result)) {
@@ -551,7 +552,6 @@ static inline void zend_assign_to_object(znode *result, zval **object_ptr, zval
        }
        
        /* here we are sure we are dealing with an object */
-       object = *object_ptr;
 
        /* separate our value if necessary */
        if (value_op->op_type == IS_TMP_VAR) {