diff options
author | Xinchen Hui <laruence@gmail.com> | 2016-11-21 11:46:03 +0800 |
---|---|---|
committer | Xinchen Hui <laruence@gmail.com> | 2016-11-21 11:46:03 +0800 |
commit | 270f9a0216ebc7c02b5fa7f5fee3d59015a6dfff (patch) | |
tree | 25b188ff20ebf5b72b64e0987adedeacefcbb328 | |
parent | f284479734f1612c06a9d8987453a533ddea4a6e (diff) | |
parent | a39d2f8ea1e41a7e8b81c8b14c5faa9fd8bab179 (diff) | |
download | php-git-270f9a0216ebc7c02b5fa7f5fee3d59015a6dfff.tar.gz |
Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0:
Update NEWS
Fix memory leak(null coalescing operator with Spl hash)
-rw-r--r-- | Zend/zend_object_handlers.c | 2 | ||||
-rw-r--r-- | ext/spl/tests/observer_010.phpt | 15 |
2 files changed, 17 insertions, 0 deletions
diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index 434102035c..04c828872d 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -792,9 +792,11 @@ zval *zend_std_read_dimension(zval *object, zval *offset, int type, zval *rv) /* if (type == BP_VAR_IS) { zend_call_method_with_1_params(object, ce, NULL, "offsetexists", rv, offset); if (UNEXPECTED(Z_ISUNDEF_P(rv))) { + zval_ptr_dtor(offset); return NULL; } if (!i_zend_is_true(rv)) { + zval_ptr_dtor(offset); zval_ptr_dtor(rv); return &EG(uninitialized_zval); } diff --git a/ext/spl/tests/observer_010.phpt b/ext/spl/tests/observer_010.phpt new file mode 100644 index 0000000000..5cedff8c7c --- /dev/null +++ b/ext/spl/tests/observer_010.phpt @@ -0,0 +1,15 @@ +--TEST-- +SPL: SplObjectStorage null coalescing operator memory leak +--FILE-- +<?php +// In maintainer zts mode, this should no longer +// detect memory leaks for the objects +$a = new stdClass(); +$b = new stdClass(); +$map = new SplObjectStorage(); +$map[$a] = 'foo'; +var_dump($map[$b] ?? null); +var_dump($map[$a] ?? null); +--EXPECTF-- +NULL +string(3) "foo" |