Skip to content

Commit 6323c13

Browse files
committed
Merge branch 'PHP-7.4'
2 parents afb69b6 + c45f195 commit 6323c13

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

Zend/zend_execute_API.c

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,21 @@ void shutdown_executor(void) /* {{{ */
316316
}
317317
} ZEND_HASH_FOREACH_END();
318318

319+
/* Also release error and exception handlers, which may hold objects. */
320+
if (Z_TYPE(EG(user_error_handler)) != IS_UNDEF) {
321+
zval_ptr_dtor(&EG(user_error_handler));
322+
ZVAL_UNDEF(&EG(user_error_handler));
323+
}
324+
325+
if (Z_TYPE(EG(user_exception_handler)) != IS_UNDEF) {
326+
zval_ptr_dtor(&EG(user_exception_handler));
327+
ZVAL_UNDEF(&EG(user_exception_handler));
328+
}
329+
330+
zend_stack_clean(&EG(user_error_handlers_error_reporting), NULL, 1);
331+
zend_stack_clean(&EG(user_error_handlers), (void (*)(void *))ZVAL_PTR_DTOR, 1);
332+
zend_stack_clean(&EG(user_exception_handlers), (void (*)(void *))ZVAL_PTR_DTOR, 1);
333+
319334
#if ZEND_DEBUG
320335
if (gc_enabled() && !CG(unclean_shutdown)) {
321336
gc_collect_cycles();
@@ -342,22 +357,6 @@ void shutdown_executor(void) /* {{{ */
342357
zend_hash_discard(EG(class_table), EG(persistent_classes_count));
343358
zend_cleanup_internal_classes();
344359
} else {
345-
/* remove error handlers before destroying classes and functions,
346-
* so that if handler used some class, crash would not happen */
347-
if (Z_TYPE(EG(user_error_handler)) != IS_UNDEF) {
348-
zval_ptr_dtor(&EG(user_error_handler));
349-
ZVAL_UNDEF(&EG(user_error_handler));
350-
}
351-
352-
if (Z_TYPE(EG(user_exception_handler)) != IS_UNDEF) {
353-
zval_ptr_dtor(&EG(user_exception_handler));
354-
ZVAL_UNDEF(&EG(user_exception_handler));
355-
}
356-
357-
zend_stack_clean(&EG(user_error_handlers_error_reporting), NULL, 1);
358-
zend_stack_clean(&EG(user_error_handlers), (void (*)(void *))ZVAL_PTR_DTOR, 1);
359-
zend_stack_clean(&EG(user_exception_handlers), (void (*)(void *))ZVAL_PTR_DTOR, 1);
360-
361360
zend_vm_stack_destroy();
362361

363362
if (EG(full_tables_cleanup)) {

Zend/zend_objects_API.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ ZEND_API void ZEND_FASTCALL zend_objects_store_free_object_storage(zend_objects_
8787
return;
8888
}
8989

90-
/* Free object contents, but don't free objects themselves, so they show up as leaks */
90+
/* Free object contents, but don't free objects themselves, so they show up as leaks.
91+
* Also add a ref to all objects, so the object can't be freed by something else later. */
9192
end = objects->object_buckets + 1;
9293
obj_ptr = objects->object_buckets + objects->top;
9394

@@ -101,7 +102,6 @@ ZEND_API void ZEND_FASTCALL zend_objects_store_free_object_storage(zend_objects_
101102
if (obj->handlers->free_obj != zend_object_std_dtor) {
102103
GC_ADDREF(obj);
103104
obj->handlers->free_obj(obj);
104-
GC_DELREF(obj);
105105
}
106106
}
107107
}
@@ -115,7 +115,6 @@ ZEND_API void ZEND_FASTCALL zend_objects_store_free_object_storage(zend_objects_
115115
GC_ADD_FLAGS(obj, IS_OBJ_FREE_CALLED);
116116
GC_ADDREF(obj);
117117
obj->handlers->free_obj(obj);
118-
GC_DELREF(obj);
119118
}
120119
}
121120
} while (obj_ptr != end);

0 commit comments

Comments
 (0)