com php-src: Fixed bug #78409: NEWS ext/spl/spl_array.c e xt/spl/tests/bug78409.phpt
| From: | Nikita Popov | Date: | Thu, 15 Aug 2019 08:40:28 +0000 |
| Subject: | com php-src: Fixed bug #78409: NEWS ext/spl/spl_array.c e xt/spl/tests/bug78409.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-107929@lists.php.net to get a copy of this message | ||
Commit: 34885408db9e16c48e8c25195c39e0ef758faaaa
Author: Nikita Popov <nikita.ppv@gmail.com> Thu, 15 Aug 2019 10:38:43 +0200
Parents: 65ea6bbdc6ee44258c560b1632e22710cfba59d0
Branches: PHP-7.4 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=34885408db9e16c48e8c25195c39e0ef758faaaa
Log:
Fixed bug #78409
This removes an incorrect optimization (I think this code used to be
necessary to properly handle references in the Serializable based
implementation, but now this code just avoids an array duplication
in a way that is not sound).
Bugs:
https://bugs.php.net/78409
Changed paths:
M NEWS
M ext/spl/spl_array.c
A ext/spl/tests/bug78409.phpt
Diff:
diff --git a/NEWS b/NEWS
index 64f8a51..5a04cda 100644
--- a/NEWS
+++ b/NEWS
@@ -21,6 +21,10 @@ PHP NEWS
. Fixed bug #78410 (Cannot "manually" unserialize class that is final and
extends an internal one). (Nikita)
+- SPL:
+ . Fixed bug #78409 (Segfault when creating instance of ArrayIterator without
+ constructor). (Nikita)
+
08 Aug 2019, PHP 7.4.0beta2
- Core:
diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c
index 32f1fd8..90861b4 100644
--- a/ext/spl/spl_array.c
+++ b/ext/spl/spl_array.c
@@ -1875,11 +1875,6 @@ SPL_METHOD(Array, __unserialize)
if (flags & SPL_ARRAY_IS_SELF) {
zval_ptr_dtor(&intern->array);
ZVAL_UNDEF(&intern->array);
- } else if (Z_TYPE_P(storage_zv) == IS_ARRAY) {
- zval_ptr_dtor(&intern->array);
- ZVAL_COPY_VALUE(&intern->array, storage_zv);
- ZVAL_NULL(storage_zv);
- SEPARATE_ARRAY(&intern->array);
} else {
spl_array_set_array(ZEND_THIS, intern, storage_zv, 0L, 1);
}
diff --git a/ext/spl/tests/bug78409.phpt b/ext/spl/tests/bug78409.phpt
new file mode 100644
index 0000000..f59015f
--- /dev/null
+++ b/ext/spl/tests/bug78409.phpt
@@ -0,0 +1,26 @@
+--TEST--
+Bug #78409: Segfault when creating instance of ArrayIterator without constructor
+--FILE--
+<?php
+
+$a = new ArrayObject;
+$u = [
+ 0,
+ [],
+ [],
+];
+$a->__unserialize($u);
+var_dump($u);
+
+?>
+--EXPECT--
+array(3) {
+ [0]=>
+ int(0)
+ [1]=>
+ array(0) {
+ }
+ [2]=>
+ array(0) {
+ }
+}