mirror of
https://github.com/php/php-src.git
synced 2024-11-23 09:54:15 +08:00
Fixed memory leak (Bob)
This commit is contained in:
parent
0da08fe595
commit
63ea4d194b
@ -1412,11 +1412,11 @@ static zend_never_inline void zend_pre_incdec_overloaded_property(zval *object,
|
||||
zval rv;
|
||||
|
||||
if (Z_OBJ_HT_P(object)->read_property && Z_OBJ_HT_P(object)->write_property) {
|
||||
zval *z, obj;
|
||||
zval *z, *zptr, obj;
|
||||
|
||||
ZVAL_OBJ(&obj, Z_OBJ_P(object));
|
||||
Z_ADDREF(obj);
|
||||
z = Z_OBJ_HT(obj)->read_property(&obj, property, BP_VAR_R, cache_slot, &rv);
|
||||
zptr = z = Z_OBJ_HT(obj)->read_property(&obj, property, BP_VAR_R, cache_slot, &rv);
|
||||
if (UNEXPECTED(EG(exception))) {
|
||||
OBJ_RELEASE(Z_OBJ(obj));
|
||||
return;
|
||||
@ -1443,7 +1443,7 @@ static zend_never_inline void zend_pre_incdec_overloaded_property(zval *object,
|
||||
}
|
||||
Z_OBJ_HT(obj)->write_property(&obj, property, z, cache_slot);
|
||||
OBJ_RELEASE(Z_OBJ(obj));
|
||||
zval_ptr_dtor(z);
|
||||
zval_ptr_dtor(zptr);
|
||||
} else {
|
||||
zend_error(E_WARNING, "Attempt to increment/decrement property of non-object");
|
||||
if (UNEXPECTED(result)) {
|
||||
|
20
tests/lang/operators/overloaded_property_ref.phpt
Normal file
20
tests/lang/operators/overloaded_property_ref.phpt
Normal file
@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
Operators on overlaoded property reference
|
||||
--FILE--
|
||||
<?php
|
||||
class C {
|
||||
function __construct() { $this->bar = str_repeat("1", 2); }
|
||||
function &__get($x) { return $this->bar; }
|
||||
function __set($x, $v) { $this->bar = $v; }
|
||||
}
|
||||
$x = new C;
|
||||
var_dump(++$x->foo);
|
||||
$x = new C;
|
||||
var_dump($x->foo++);
|
||||
$x = new C;
|
||||
var_dump($x->foo += 2);
|
||||
?>
|
||||
--EXPECT--
|
||||
int(12)
|
||||
string(2) "11"
|
||||
int(13)
|
Loading…
Reference in New Issue
Block a user