]> granicus.if.org Git - php/commitdiff
Fixed Bug #62005 (unexpected behavior when incrementally assigning to a member of...
authorXinchen Hui <laruence@php.net>
Sat, 12 May 2012 05:13:44 +0000 (13:13 +0800)
committerXinchen Hui <laruence@php.net>
Sat, 12 May 2012 05:13:44 +0000 (13:13 +0800)
NEWS
Zend/tests/bug62005.phpt [new file with mode: 0644]
Zend/zend_execute.c

diff --git a/NEWS b/NEWS
index e9c13701cfd4bac5bafba134a0b8fdeaaffcfb23..1057db7d846737502e0c0d921b59ed485613cbf9 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,8 @@ PHP                                                                        NEWS
     (Laruence)
 
 - Core:
+  . Fixed bug #62005 (unexpected behavior when incrementally assigning to a 
+    member of a null object). (Laruence)
   . Fixed bug #61730 (Segfault from array_walk modifying an array passed by
     reference). (Laruence)
   . Fixed missing bound check in iptcparse(). (chris at chiappa.net)
diff --git a/Zend/tests/bug62005.phpt b/Zend/tests/bug62005.phpt
new file mode 100644 (file)
index 0000000..4ff4b2c
--- /dev/null
@@ -0,0 +1,15 @@
+--TEST--
+Bug #62005 (unexpected behavior when incrementally assigning to a member of a null object)
+--FILE--
+<?php
+function add_points($player, $points) {
+    $player->energy += $points;
+    print_r($player);
+}
+add_points(NULL, 2);
+--EXPECTF--
+Strict Standards: Creating default object from empty value in %sbug62005.php on line %d
+stdClass Object
+(
+    [energy] => 2
+)
index 705c71389db317cd2b247f0d8b31ad0b35bd1c68..4423921649f6fc6e2e418fce092f0346094732f1 100644 (file)
@@ -432,11 +432,10 @@ static inline void make_real_object(zval **object_ptr TSRMLS_DC)
                || (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");
-
                SEPARATE_ZVAL_IF_NOT_REF(object_ptr);
                zval_dtor(*object_ptr);
                object_init(*object_ptr);
+               zend_error(E_STRICT, "Creating default object from empty value");
        }
 }