summaryrefslogtreecommitdiff
path: root/src/plugins/perl/weechat-perl-api.c
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2014-02-22 17:10:01 +0100
committerSebastien Helleu <flashcode@flashtux.org>2014-02-22 17:10:01 +0100
commit0c3835d82470f7dff15fd6ece6f7ded0520e3419 (patch)
tree917681a6f664f21910987850bc2ee52eac1a37e2 /src/plugins/perl/weechat-perl-api.c
parenta08679c887b5ec542d2da39ade1fbc1c806c732b (diff)
downloadweechat-0c3835d82470f7dff15fd6ece6f7ded0520e3419.zip
scripts: fix crash when a signal is received with type "int" and NULL pointer in signal_data
Diffstat (limited to 'src/plugins/perl/weechat-perl-api.c')
-rw-r--r--src/plugins/perl/weechat-perl-api.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/plugins/perl/weechat-perl-api.c b/src/plugins/perl/weechat-perl-api.c
index 32e8f3e7b..83ba39a2b 100644
--- a/src/plugins/perl/weechat-perl-api.c
+++ b/src/plugins/perl/weechat-perl-api.c
@@ -2399,7 +2399,7 @@ weechat_perl_api_hook_signal_cb (void *data, const char *signal, const char *typ
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;
@@ -2415,9 +2415,13 @@ weechat_perl_api_hook_signal_cb (void *data, const char *signal, const char *typ
}
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)
{