Permalink
Browse files

Fix segfault in case the destructor of an object kills its own weakref

  • Loading branch information...
1 parent 4fbd2ca commit a7e4aaeea68d01386f9a51bace324840ce884aaf @colder committed Mar 28, 2012
Showing with 4 additions and 1 deletion.
  1. +4 −1 php_weakref.c
View
@@ -56,12 +56,15 @@ void wr_store_dtor(void *ref_object, zend_object_handle ref_handle TSRMLS_DC) /*
wr_store *store = WR_G(store);
zend_objects_store_dtor_t orig_dtor = store->objs[ref_handle].orig_dtor;
wr_store_data data = store->objs[ref_handle];
- wr_ref_list *list_entry = data.wrefs_head;
+ wr_ref_list *list_entry;
EG(objects_store).object_buckets[ref_handle].bucket.obj.dtor = data.orig_dtor;
orig_dtor(ref_object, ref_handle TSRMLS_CC);
+ /* data might have changed if the destructor freed weakrefs, we reload from store */
+ list_entry = store->objs[ref_handle].wrefs_head;
+
while (list_entry != NULL) {
wr_ref_list *next = list_entry->next;
list_entry->dtor(ref_object, ref_handle, list_entry->obj TSRMLS_CC);

0 comments on commit a7e4aae

Please sign in to comment.