]> granicus.if.org Git - php/commitdiff
Make unserialize() ref unwrapping compatible with 7.0
authorNikita Popov <nikic@php.net>
Mon, 16 Jan 2017 13:25:58 +0000 (14:25 +0100)
committerNikita Popov <nikic@php.net>
Mon, 16 Jan 2017 13:25:58 +0000 (14:25 +0100)
Also fix output difference in merged test (unrelated).

ext/standard/tests/serialize/bug69425.phpt
ext/standard/var.c

index bfa8b9b369fda06aaafc9338e14d7ba272316694..e39f855f23aae3fa4a6668789a55063632086d5b 100644 (file)
@@ -26,7 +26,7 @@ var_dump($data);
 int(1)
 array(2) {
   [0]=>
-  object(DateInterval)#1 (15) {
+  object(DateInterval)#1 (16) {
     ["y"]=>
     int(-1)
     ["m"]=>
@@ -39,6 +39,8 @@ array(2) {
     int(-1)
     ["s"]=>
     int(-1)
+    ["f"]=>
+    float(-1)
     ["weekday"]=>
     int(-1)
     ["weekday_behavior"]=>
index 490a68c1759b745b2f28d6234a8352046d545562..03368287d7d69b63ff50a460d4446ba3aeb43279 100644 (file)
@@ -1118,7 +1118,6 @@ PHP_FUNCTION(unserialize)
                }
                RETVAL_FALSE;
        } else {
-               ZVAL_DEREF(retval);
                ZVAL_COPY(return_value, retval);
        }
 
@@ -1130,6 +1129,13 @@ PHP_FUNCTION(unserialize)
        /* Reset to previous allowed_classes in case this is a nested call */
        php_var_unserialize_set_allowed_classes(var_hash, prev_class_hash);
        PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
+
+       /* Per calling convention we must not return a reference here, so unwrap. We're doing this at
+        * the very end, because __wakeup() calls performed during UNSERIALIZE_DESTROY might affect
+        * the value we unwrap here. This is compatible with behavior in PHP <=7.0. */
+       if (Z_ISREF_P(return_value)) {
+               zend_unwrap_reference(return_value);
+       }
 }
 /* }}} */