From 0c3835d82470f7dff15fd6ece6f7ded0520e3419 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Sat, 22 Feb 2014 17:10:01 +0100 Subject: scripts: fix crash when a signal is received with type "int" and NULL pointer in signal_data --- src/plugins/guile/weechat-guile-api.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/plugins/guile/weechat-guile-api.c') diff --git a/src/plugins/guile/weechat-guile-api.c b/src/plugins/guile/weechat-guile-api.c index 2136092b7..f32a166f3 100644 --- a/src/plugins/guile/weechat-guile-api.c +++ b/src/plugins/guile/weechat-guile-api.c @@ -2365,7 +2365,7 @@ weechat_guile_api_hook_signal_cb (void *data, const char *signal, struct t_plugin_script_cb *script_callback; void *func_argv[3]; char empty_arg[1] = { '\0' }; - static char value_str[64]; + static char str_value[64]; int *rc, ret, free_needed; script_callback = (struct t_plugin_script_cb *)data; @@ -2381,9 +2381,13 @@ weechat_guile_api_hook_signal_cb (void *data, const char *signal, } else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_INT) == 0) { - snprintf (value_str, sizeof (value_str) - 1, - "%d", *((int *)signal_data)); - func_argv[2] = value_str; + str_value[0] = '\0'; + if (signal_data) + { + snprintf (str_value, sizeof (str_value), + "%d", *((int *)signal_data)); + } + func_argv[2] = str_value; } else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_POINTER) == 0) { -- cgit v1.2.3