com php-src: Make unserialize() ref unwrapping compatible with 7.0: ext/standard/tests/serialize/bug69425.phpt ext/standard/var.c
| From: | Nikita Popov | Date: | Mon, 16 Jan 2017 13:25:58 +0000 |
| Subject: | com php-src: Make unserialize() ref unwrapping compatible with 7.0: ext/standard/tests/serialize/bug69425.phpt ext/standard/var.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-96749@lists.php.net to get a copy of this message | ||
Commit: 29433f9fd581574e11b1ccb2942d1022e9e2173a
Author: Nikita Popov <nikic@php.net> Mon, 16 Jan 2017 14:25:58 +0100
Parents: 590ef15f6a492c7edddf8e76abdb608424f39fc3
Branches: PHP-7.1 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=29433f9fd581574e11b1ccb2942d1022e9e2173a
Log:
Make unserialize() ref unwrapping compatible with 7.0
Also fix output difference in merged test (unrelated).
Changed paths:
M ext/standard/tests/serialize/bug69425.phpt
M ext/standard/var.c
Diff:
diff --git a/ext/standard/tests/serialize/bug69425.phpt b/ext/standard/tests/serialize/bug69425.phpt
index bfa8b9b..e39f855 100644
--- a/ext/standard/tests/serialize/bug69425.phpt
+++ b/ext/standard/tests/serialize/bug69425.phpt
@@ -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"]=>
diff --git a/ext/standard/var.c b/ext/standard/var.c
index 490a68c..0336828 100644
--- a/ext/standard/var.c
+++ b/ext/standard/var.c
@@ -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);
+ }
}
/* }}} */