com php-src: Fix bug #66127 (Segmentation fault with ArrayObject unset): NEWS ext/spl/spl_array.c ext/spl/tests/bug66127 .phpt
ext/spl/tests/iterator_035.phpt
| From: | Stanislav Malyshev | Date: | Wed, 11 Jun 2014 06:24:11 +0000 |
| Subject: | com php-src: Fix bug #66127 (Segmentation fault with ArrayObject unset): NEWS ext/spl/spl_array.c ext/spl/tests/bug66127 .phpt ext/spl/tests/iterator_035.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-78830@lists.php.net to get a copy of this message | ||
Commit: 2b04d689724bdfd5db9351c017566e2f51d61568
Author: Stanislav Malyshev <stas@php.net> Tue, 10 Jun 2014 23:17:30 -0700
Parents: 0235a8acdc9b99d4d3d4dd107b75d7eb6ca0ef97
Branches: PHP-5.4.30
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=2b04d689724bdfd5db9351c017566e2f51d61568
Log:
Fix bug #66127 (Segmentation fault with ArrayObject unset)
Bugs:
https://bugs.php.net/66127
Changed paths:
M NEWS
M ext/spl/spl_array.c
A ext/spl/tests/bug66127.phpt
M ext/spl/tests/iterator_035.phpt
Diff:
diff --git a/NEWS b/NEWS
index 853732f..f0367a8 100644
--- a/NEWS
+++ b/NEWS
@@ -41,6 +41,7 @@ PHP NEWS
. Implemented FR #49898 (Add SoapClient::__getCookies()). (Boro Sitnikovski)
- SPL:
+ . Fixed bug #66127 (Segmentation fault with ArrayObject unset). (Stas)
. Fixed bug #67359 (Segfault in recursiveDirectoryIterator). (Laruence)
. Fixed bug #67360 (Missing element after ArrayObject::getIterator). (Adam)
diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c
index 34f3a38..758947a 100644
--- a/ext/spl/spl_array.c
+++ b/ext/spl/spl_array.c
@@ -402,7 +402,7 @@ static zval *spl_array_read_dimension_ex(int check_inherited, zval *object, zval
/* When in a write context,
* ZE has to be fooled into thinking this is in a reference set
* by separating (if necessary) and returning as an is_ref=1 zval (even if refcount == 1) */
- if ((type == BP_VAR_W || type == BP_VAR_RW || type == BP_VAR_UNSET) && !Z_ISREF_PP(ret)) {
+ if ((type == BP_VAR_W || type == BP_VAR_RW || type == BP_VAR_UNSET) && !Z_ISREF_PP(ret)
&& ret != &EG(uninitialized_zval_ptr)) {
if (Z_REFCOUNT_PP(ret) > 1) {
zval *newval;
diff --git a/ext/spl/tests/bug66127.phpt b/ext/spl/tests/bug66127.phpt
new file mode 100644
index 0000000..b5d1dca
--- /dev/null
+++ b/ext/spl/tests/bug66127.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Bug #66127 (Segmentation fault with ArrayObject unset)
+--INI--
+error_reporting = E_ALL & ~E_NOTICE
+--FILE--
+<?php
+function crash()
+{
+ set_error_handler(function () {});
+ $var = 1;
+ trigger_error('error');
+ $var2 = $var;
+ $var3 = $var;
+ trigger_error('error');
+}
+
+$items = new ArrayObject();
+
+unset($items[0]);
+unset($items[0][0]);
+crash();
+echo "Worked!\n";
+?>
+--EXPECT--
+Worked!
diff --git a/ext/spl/tests/iterator_035.phpt b/ext/spl/tests/iterator_035.phpt
index 9ce098b..fc0271e 100644
--- a/ext/spl/tests/iterator_035.phpt
+++ b/ext/spl/tests/iterator_035.phpt
@@ -12,4 +12,6 @@ $a[] = &$tmp;
echo "Done\n";
?>
--EXPECTF--
+Notice: Indirect modification of overloaded element of ArrayIterator has no effect in %s on line %d
+
Fatal error: Cannot assign by reference to overloaded object in %s on line %d