diff options
author | Xinchen Hui <laruence@gmail.com> | 2016-11-21 11:46:13 +0800 |
---|---|---|
committer | Xinchen Hui <laruence@gmail.com> | 2016-11-21 11:46:13 +0800 |
commit | f33bfd4e447d7d7717afa031c2fbfc022d5987ce (patch) | |
tree | 0d48c167684a53d18365e36067870ec299239cd9 | |
parent | e59089c6e544d1d2c7a6d9bf29398f50000797c9 (diff) | |
parent | 270f9a0216ebc7c02b5fa7f5fee3d59015a6dfff (diff) | |
download | php-git-f33bfd4e447d7d7717afa031c2fbfc022d5987ce.tar.gz |
Merge branch 'PHP-7.1'
* PHP-7.1:
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 955d5cd912..2273b06fb3 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -778,9 +778,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" |