summaryrefslogtreecommitdiff
path: root/Zend/zend_objects_API.c
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2008-02-19 12:00:53 +0000
committerDmitry Stogov <dmitry@php.net>2008-02-19 12:00:53 +0000
commita4b872a6d8e9bfe532db6ebd751ef126dfd4a650 (patch)
treeaba9ebe2780ca051532ed407a98b782f272db2f9 /Zend/zend_objects_API.c
parent23e18f966bd2b7e710e76ea5e4fb588ec35cb168 (diff)
downloadphp-git-a4b872a6d8e9bfe532db6ebd751ef126dfd4a650.tar.gz
iFixed memory leak
Diffstat (limited to 'Zend/zend_objects_API.c')
-rw-r--r--Zend/zend_objects_API.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/Zend/zend_objects_API.c b/Zend/zend_objects_API.c
index 2fded2a1f9..f87472aaf0 100644
--- a/Zend/zend_objects_API.c
+++ b/Zend/zend_objects_API.c
@@ -158,8 +158,7 @@ ZEND_API void zend_objects_store_add_ref_by_handle(zend_object_handle handle TSR
#define ZEND_OBJECTS_STORE_ADD_TO_FREE_LIST() \
EG(objects_store).object_buckets[handle].bucket.free_list.next = EG(objects_store).free_list_head; \
- EG(objects_store).free_list_head = handle; \
- EG(objects_store).object_buckets[handle].valid = 0;
+ EG(objects_store).free_list_head = handle;
ZEND_API void zend_objects_store_del_ref(zval *zobject TSRMLS_DC)
{
@@ -186,13 +185,12 @@ ZEND_API void zend_objects_store_del_ref_by_handle(zend_object_handle handle TSR
return;
}
- obj = &EG(objects_store).object_buckets[handle].bucket.obj;
-
/* Make sure we hold a reference count during the destructor call
otherwise, when the destructor ends the storage might be freed
when the refcount reaches 0 a second time
*/
if (EG(objects_store).object_buckets[handle].valid) {
+ obj = &EG(objects_store).object_buckets[handle].bucket.obj;
if (obj->refcount == 1) {
if (!EG(objects_store).object_buckets[handle].destructor_called) {
EG(objects_store).object_buckets[handle].destructor_called = 1;
@@ -206,6 +204,7 @@ ZEND_API void zend_objects_store_del_ref_by_handle(zend_object_handle handle TSR
}
}
if (obj->refcount == 1) {
+ EG(objects_store).object_buckets[handle].valid = 0;
GC_REMOVE_ZOBJ_FROM_BUFFER(obj);
if (obj->free_storage) {
zend_try {
@@ -217,19 +216,20 @@ ZEND_API void zend_objects_store_del_ref_by_handle(zend_object_handle handle TSR
ZEND_OBJECTS_STORE_ADD_TO_FREE_LIST();
}
}
- }
- obj->refcount--;
+ obj->refcount--;
#if ZEND_DEBUG_OBJECTS
- if (obj->refcount == 0) {
- fprintf(stderr, "Deallocated object id #%d\n", handle);
- } else {
- fprintf(stderr, "Decreased refcount of object id #%d\n", handle);
- }
+ if (obj->refcount == 0) {
+ fprintf(stderr, "Deallocated object id #%d\n", handle);
+ } else {
+ fprintf(stderr, "Decreased refcount of object id #%d\n", handle);
+ }
#endif
- if (failure) {
- zend_bailout();
+
+ if (failure) {
+ zend_bailout();
+ }
}
}