Skip to content

Commit caee59b

Browse files
committed
everted (this part was committed by mistake)
1 parent f4dc0f2 commit caee59b

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

Diff for: Zend/zend_objects_API.c

+13-13
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ ZEND_API void zend_objects_store_add_ref_by_handle(zend_object_handle handle TSR
158158

159159
#define ZEND_OBJECTS_STORE_ADD_TO_FREE_LIST() \
160160
EG(objects_store).object_buckets[handle].bucket.free_list.next = EG(objects_store).free_list_head; \
161-
EG(objects_store).free_list_head = handle;
161+
EG(objects_store).free_list_head = handle; \
162+
EG(objects_store).object_buckets[handle].valid = 0;
162163

163164
ZEND_API void zend_objects_store_del_ref(zval *zobject TSRMLS_DC)
164165
{
@@ -185,12 +186,13 @@ ZEND_API void zend_objects_store_del_ref_by_handle(zend_object_handle handle TSR
185186
return;
186187
}
187188

189+
obj = &EG(objects_store).object_buckets[handle].bucket.obj;
190+
188191
/* Make sure we hold a reference count during the destructor call
189192
otherwise, when the destructor ends the storage might be freed
190193
when the refcount reaches 0 a second time
191194
*/
192195
if (EG(objects_store).object_buckets[handle].valid) {
193-
obj = &EG(objects_store).object_buckets[handle].bucket.obj;
194196
if (obj->refcount == 1) {
195197
if (!EG(objects_store).object_buckets[handle].destructor_called) {
196198
EG(objects_store).object_buckets[handle].destructor_called = 1;
@@ -204,7 +206,6 @@ ZEND_API void zend_objects_store_del_ref_by_handle(zend_object_handle handle TSR
204206
}
205207
}
206208
if (obj->refcount == 1) {
207-
EG(objects_store).object_buckets[handle].valid = 0;
208209
GC_REMOVE_ZOBJ_FROM_BUFFER(obj);
209210
if (obj->free_storage) {
210211
zend_try {
@@ -216,20 +217,19 @@ ZEND_API void zend_objects_store_del_ref_by_handle(zend_object_handle handle TSR
216217
ZEND_OBJECTS_STORE_ADD_TO_FREE_LIST();
217218
}
218219
}
220+
}
219221

220-
obj->refcount--;
222+
obj->refcount--;
221223

222224
#if ZEND_DEBUG_OBJECTS
223-
if (obj->refcount == 0) {
224-
fprintf(stderr, "Deallocated object id #%d\n", handle);
225-
} else {
226-
fprintf(stderr, "Decreased refcount of object id #%d\n", handle);
227-
}
225+
if (obj->refcount == 0) {
226+
fprintf(stderr, "Deallocated object id #%d\n", handle);
227+
} else {
228+
fprintf(stderr, "Decreased refcount of object id #%d\n", handle);
229+
}
228230
#endif
229-
230-
if (failure) {
231-
zend_bailout();
232-
}
231+
if (failure) {
232+
zend_bailout();
233233
}
234234
}
235235

0 commit comments

Comments
 (0)