diff options
author | Kalle Sommer Nielsen <kalle@php.net> | 2016-11-21 15:19:29 +0100 |
---|---|---|
committer | Kalle Sommer Nielsen <kalle@php.net> | 2016-11-21 15:19:29 +0100 |
commit | fa2fcd53c68b620321b4aa0dc1e140719407833e (patch) | |
tree | 8f609f1f31e766595685a2ae7c6d7dc50f48fa95 | |
parent | 8efbcf18a169fe07dd21ab2c9a4c16fe3e18e4e3 (diff) | |
parent | 51f59739b647613f748f0866501f8c3b86427d2f (diff) | |
download | php-git-fa2fcd53c68b620321b4aa0dc1e140719407833e.tar.gz |
Merge branch 'master' of git.php.net:php-src
-rw-r--r-- | Zend/zend_object_handlers.c | 2 | ||||
-rw-r--r-- | Zend/zend_objects_API.c | 6 | ||||
-rw-r--r-- | Zend/zend_objects_API.h | 7 | ||||
-rw-r--r-- | ext/spl/tests/observer_010.phpt | 15 |
4 files changed, 23 insertions, 7 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/Zend/zend_objects_API.c b/Zend/zend_objects_API.c index 00d9425f18..d828f55401 100644 --- a/Zend/zend_objects_API.c +++ b/Zend/zend_objects_API.c @@ -210,12 +210,6 @@ ZEND_API void zend_object_store_set_object(zval *zobject, zend_object *object) EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(zobject)] = object; } -/* Called when the ctor was terminated by an exception */ -ZEND_API void zend_object_store_ctor_failed(zend_object *obj) -{ - GC_FLAGS(obj) |= IS_OBJ_DESTRUCTOR_CALLED; -} - ZEND_API zend_object_handlers *zend_get_std_object_handlers(void) { return &std_object_handlers; diff --git a/Zend/zend_objects_API.h b/Zend/zend_objects_API.h index 7dfad70fbc..ac4485fea3 100644 --- a/Zend/zend_objects_API.h +++ b/Zend/zend_objects_API.h @@ -61,7 +61,12 @@ ZEND_API void zend_objects_store_free(zend_object *object); /* See comment in zend_objects_API.c before you use this */ ZEND_API void zend_object_store_set_object(zval *zobject, zend_object *object); -ZEND_API void zend_object_store_ctor_failed(zend_object *object); + +/* Called when the ctor was terminated by an exception */ +static zend_always_inline void zend_object_store_ctor_failed(zend_object *obj) +{ + GC_FLAGS(obj) |= IS_OBJ_DESTRUCTOR_CALLED; +} ZEND_API void zend_objects_store_free_object_storage(zend_objects_store *objects); 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" |