Patch wr_weakref-fix-dtor-release for Weakref Bug #69131
Patch version 2015-02-27 00:09 UTC
Return to Bug #69131 |
Download this patch
Patch Revisions:
Developer: p@wspnr.com
--- a/wr_weakref.c
+++ b/wr_weakref.c
@@ -35,6 +35,15 @@ WEAKREF_API zend_class_entry *wr_ce_WeakRef;
static void wr_weakref_ref_dtor(void *ref_object, zend_object_handle ref_handle, zend_object *wref_obj TSRMLS_DC) { /* {{{ */
wr_weakref_object *wref = (wr_weakref_object *)wref_obj;
+
+ while (wref->valid && wref->acquired > 0) {
+ if (wr_weakref_ref_release(wref TSRMLS_CC) != SUCCESS) {
+ // shouldn't occur
+ zend_throw_exception(spl_ce_RuntimeException, "Failed to correctly release the reference on destruct", 0 TSRMLS_CC);
+ break;
+ }
+ }
+
wref->valid = 0;
}
/* }}} */
|