@@ -158,7 +158,8 @@ ZEND_API void zend_objects_store_add_ref_by_handle(zend_object_handle handle TSR
158
158
159
159
#define ZEND_OBJECTS_STORE_ADD_TO_FREE_LIST () \
160
160
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;
162
163
163
164
ZEND_API void zend_objects_store_del_ref (zval * zobject TSRMLS_DC )
164
165
{
@@ -185,12 +186,13 @@ ZEND_API void zend_objects_store_del_ref_by_handle(zend_object_handle handle TSR
185
186
return ;
186
187
}
187
188
189
+ obj = & EG (objects_store ).object_buckets [handle ].bucket .obj ;
190
+
188
191
/* Make sure we hold a reference count during the destructor call
189
192
otherwise, when the destructor ends the storage might be freed
190
193
when the refcount reaches 0 a second time
191
194
*/
192
195
if (EG (objects_store ).object_buckets [handle ].valid ) {
193
- obj = & EG (objects_store ).object_buckets [handle ].bucket .obj ;
194
196
if (obj -> refcount == 1 ) {
195
197
if (!EG (objects_store ).object_buckets [handle ].destructor_called ) {
196
198
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
204
206
}
205
207
}
206
208
if (obj -> refcount == 1 ) {
207
- EG (objects_store ).object_buckets [handle ].valid = 0 ;
208
209
GC_REMOVE_ZOBJ_FROM_BUFFER (obj );
209
210
if (obj -> free_storage ) {
210
211
zend_try {
@@ -216,20 +217,19 @@ ZEND_API void zend_objects_store_del_ref_by_handle(zend_object_handle handle TSR
216
217
ZEND_OBJECTS_STORE_ADD_TO_FREE_LIST ();
217
218
}
218
219
}
220
+ }
219
221
220
- obj -> refcount -- ;
222
+ obj -> refcount -- ;
221
223
222
224
#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
+ }
228
230
#endif
229
-
230
- if (failure ) {
231
- zend_bailout ();
232
- }
231
+ if (failure ) {
232
+ zend_bailout ();
233
233
}
234
234
}
235
235
0 commit comments