Skip to content

Commit 270f9a0

Browse files
committed
Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0: Update NEWS Fix memory leak(null coalescing operator with Spl hash)
2 parents f284479 + a39d2f8 commit 270f9a0

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

Zend/zend_object_handlers.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,9 +792,11 @@ zval *zend_std_read_dimension(zval *object, zval *offset, int type, zval *rv) /*
792792
if (type == BP_VAR_IS) {
793793
zend_call_method_with_1_params(object, ce, NULL, "offsetexists", rv, offset);
794794
if (UNEXPECTED(Z_ISUNDEF_P(rv))) {
795+
zval_ptr_dtor(offset);
795796
return NULL;
796797
}
797798
if (!i_zend_is_true(rv)) {
799+
zval_ptr_dtor(offset);
798800
zval_ptr_dtor(rv);
799801
return &EG(uninitialized_zval);
800802
}

ext/spl/tests/observer_010.phpt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
SPL: SplObjectStorage null coalescing operator memory leak
3+
--FILE--
4+
<?php
5+
// In maintainer zts mode, this should no longer
6+
// detect memory leaks for the objects
7+
$a = new stdClass();
8+
$b = new stdClass();
9+
$map = new SplObjectStorage();
10+
$map[$a] = 'foo';
11+
var_dump($map[$b] ?? null);
12+
var_dump($map[$a] ?? null);
13+
--EXPECTF--
14+
NULL
15+
string(3) "foo"

0 commit comments

Comments
 (0)