Skip to content

Commit 88d0486

Browse files
committed
Inline list iteration to avoid va_list in va_list inception problems, va_copy va_list and cleanup callback name code.
1 parent bb5ef00 commit 88d0486

File tree

3 files changed

+14
-21
lines changed

3 files changed

+14
-21
lines changed

Zend/zend.c

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,7 @@ int zend_startup(zend_utility_functions *utility_functions) /* {{{ */
851851
zend_execute_ex = dtrace_execute_ex;
852852
zend_execute_internal = dtrace_execute_internal;
853853

854-
zend_register_error_notify_callback("dtrace", dtrace_error_notify_cb);
854+
zend_register_error_notify_callback(dtrace_error_notify_cb);
855855
} else {
856856
zend_compile_file = compile_file;
857857
zend_execute_ex = execute_ex;
@@ -1769,7 +1769,6 @@ ZEND_API void zend_map_ptr_extend(size_t last)
17691769

17701770
static void zend_error_notify_callback_dtor(zend_error_notify_callback *callback)
17711771
{
1772-
free(callback->name);
17731772
}
17741773

17751774
int zend_startup_error_notify_callbacks()
@@ -1786,29 +1785,25 @@ int zend_shutdown_error_notify_callbacks()
17861785
return SUCCESS;
17871786
}
17881787

1789-
void zend_error_notify_callbacks_apply(llist_apply_func_t callback)
1788+
void zend_register_error_notify_callback(zend_error_notify_cb cb)
17901789
{
1791-
zend_llist_apply(&zend_error_notify_callbacks, callback);
1792-
}
1793-
1794-
void zend_register_error_notify_callback(const char *name, zend_error_notify_cb cb)
1795-
{
1796-
ZEND_ASSERT(name != NULL);
1797-
17981790
zend_error_notify_callback callback;
17991791

1800-
callback.name = strdup(name);
18011792
callback.notify_callback = cb;
18021793

18031794
zend_llist_add_element(&zend_error_notify_callbacks, &callback);
18041795
}
18051796

1806-
static void zend_error_notify_single_callback(zend_error_notify_callback *callback, int type, const char *error_filename, const uint32_t error_lineno, const char *format, va_list args)
1807-
{
1808-
callback->notify_callback(type, error_filename, error_lineno, format, args);
1809-
}
1810-
18111797
void zend_error_notify_all_callbacks(int type, const char *error_filename, const uint32_t error_lineno, const char *format, va_list args)
18121798
{
1813-
zend_llist_apply_with_arguments(&zend_error_notify_callbacks, (llist_apply_with_args_func_t) zend_error_notify_single_callback, 5, type, error_filename, error_lineno, format, args);
1799+
zend_llist_element *element;
1800+
zend_error_notify_callback *callback;
1801+
va_list argcopy;
1802+
1803+
for (element = zend_error_notify_callbacks.head; element; element = element->next) {
1804+
va_copy(argcopy, args);
1805+
callback = (zend_error_notify_callback*) element->data;
1806+
callback->notify_callback(type, error_filename, error_lineno, format, argcopy);
1807+
va_end(argcopy);
1808+
}
18141809
}

Zend/zend.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,15 +353,13 @@ typedef void (*zend_error_notify_cb)(int type, const char *error_filename, const
353353

354354
BEGIN_EXTERN_C()
355355
typedef struct {
356-
char *name;
357356
zend_error_notify_cb notify_callback;
358357
} zend_error_notify_callback;
359358

360-
void zend_register_error_notify_callback(const char *name, zend_error_notify_cb callback);
359+
void zend_register_error_notify_callback(zend_error_notify_cb callback);
361360
int zend_startup_error_notify_callbacks();
362361
int zend_shutdown_error_notify_callbacks();
363362
void zend_error_notify_all_callbacks(int type, const char *error_filename, const uint32_t error_lineno, const char *format, va_list args);
364-
void zend_error_notify_callbacks_apply(llist_apply_func_t callback);
365363
#if ZEND_DEBUG
366364
void report_zend_debug_error_notify_cb(int type, const char *error_filename, const uint32_t error_lineno, const char *format, va_list args);
367365
#endif

main/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2149,7 +2149,7 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
21492149
zend_update_current_locale();
21502150

21512151
#if ZEND_DEBUG
2152-
zend_register_error_notify_callback("report_zend_debug", report_zend_debug_error_notify_cb);
2152+
zend_register_error_notify_callback(report_zend_debug_error_notify_cb);
21532153
#endif
21542154

21552155
#if HAVE_TZSET

0 commit comments

Comments
 (0)