Skip to content

Commit b1bfe8d

Browse files
committed
Suggested changes by joe.
1 parent 883b446 commit b1bfe8d

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

Zend/zend.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ ZEND_TSRMLS_CACHE_DEFINE()
6060
ZEND_API zend_utility_values zend_uv;
6161
ZEND_API zend_bool zend_dtrace_enabled;
6262

63+
zend_llist zend_error_notify_callbacks;
64+
6365
/* version information */
6466
static char *zend_version_info;
6567
static uint32_t zend_version_info_length;
@@ -1767,6 +1769,7 @@ ZEND_API void zend_map_ptr_extend(size_t last)
17671769

17681770
static void zend_error_notify_callback_dtor(zend_error_notify_callback *callback)
17691771
{
1772+
free(callback->name);
17701773
}
17711774

17721775
int zend_startup_error_notify_callbacks()
@@ -1783,11 +1786,18 @@ int zend_shutdown_error_notify_callbacks()
17831786
return SUCCESS;
17841787
}
17851788

1789+
void zend_error_notify_callbacks_apply(llist_apply_func_t *callback)
1790+
{
1791+
zend_llist_apply(&zend_error_notify_callbacks, callback);
1792+
}
1793+
17861794
void zend_register_error_notify_callback(const char *name, zend_error_notify_cb cb)
17871795
{
1796+
ZEND_ASSERT(name != NULL);
1797+
17881798
zend_error_notify_callback callback;
17891799

1790-
callback.name = name;
1800+
callback.name = strdup(name);
17911801
callback.notify_callback = cb;
17921802

17931803
zend_llist_add_element(&zend_error_notify_callbacks, &callback);

Zend/zend.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,16 +351,18 @@ ZEND_API void zend_restore_error_handling(zend_error_handling *saved);
351351

352352
typedef void (*zend_error_notify_cb)(int type, const char *error_filename, const uint32_t error_lineno, const char *format, va_list args);
353353

354+
BEGIN_EXTERN_C()
354355
typedef struct {
355-
const char *name;
356+
char *name;
356357
zend_error_notify_cb notify_callback;
357358
} zend_error_notify_callback;
358359

359-
ZEND_API zend_llist zend_error_notify_callbacks;
360360
void zend_register_error_notify_callback(const char *name, zend_error_notify_cb callback);
361361
int zend_startup_error_notify_callbacks();
362362
int zend_shutdown_error_notify_callbacks();
363363
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);
365+
END_EXTERN_C()
364366

365367
#define DEBUG_BACKTRACE_PROVIDE_OBJECT (1<<0)
366368
#define DEBUG_BACKTRACE_IGNORE_ARGS (1<<1)

ext/standard/info.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ static ZEND_COLD void php_info_print_error_notify_callbacks() /* {{{ */
100100
php_info_printf("\nRegistered Error Notification Callbacks => ");
101101
}
102102

103-
zend_llist_apply(&zend_error_notify_callbacks, (llist_apply_func_t) php_info_print_error_notify_callback);
103+
zend_error_notify_callbacks_apply((llist_apply_func_t) php_info_print_error_notify_callback);
104104

105105
if (!sapi_module.phpinfo_as_text) {
106106
php_info_print("</td></tr>\n");

0 commit comments

Comments
 (0)