Skip to content

Commit 3d4c792

Browse files
committed
Fix leak with overloaded objects, when they're used just "for the hell
of it" :)
1 parent b625b03 commit 3d4c792

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Zend/zend_execute.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ static inline void zend_clean_garbage(TSRMLS_D)
7878

7979
#define PZVAL_UNLOCK(z) zend_pzval_unlock_func(z TSRMLS_CC)
8080
#define PZVAL_LOCK(z) zend_pzval_lock_func(z)
81-
#define SELECTIVE_PZVAL_LOCK(pzv, pzn) if (!((pzn)->u.EA.type & EXT_TYPE_UNUSED)) { PZVAL_LOCK(pzv); }
81+
#define RETURN_VALUE_UNUSED(pzn) (((pzn)->u.EA.type & EXT_TYPE_UNUSED))
82+
#define SELECTIVE_PZVAL_LOCK(pzv, pzn) if (!RETURN_VALUE_UNUSED(pzn)) { PZVAL_LOCK(pzv); }
83+
8284

8385
/* End of zend_execute_locks.h */
8486

@@ -1091,10 +1093,15 @@ static void zend_fetch_property_address_read(znode *result, znode *op1, znode *o
10911093
zval_dtor(offset);
10921094
}
10931095
FREE_OP(Ts, op2, EG(free_op2));
1096+
1097+
if (RETURN_VALUE_UNUSED(result) && ((*retval)->refcount == 0)) {
1098+
zval_dtor(*retval);
1099+
FREE_ZVAL(*retval);
1100+
return; /* no need for locking */
1101+
}
10941102
}
10951103

10961104
SELECTIVE_PZVAL_LOCK(*retval, result);
1097-
return;
10981105
}
10991106

11001107
static void zend_pre_incdec_property(znode *result, znode *op1, znode *op2, temp_variable * Ts, int (*incdec_op)(zval *) TSRMLS_DC)

0 commit comments

Comments
 (0)