diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2012-12-06 13:43:31 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2012-12-06 13:43:31 +0100 |
commit | 822ae765435824650ae8fe6f538489d1090c044f (patch) | |
tree | 433ffa0089d3d54c7ec767d375407aeecdae5322 /src | |
parent | d224594194e68dc8addce8a6da9001c72f6d1dcc (diff) | |
download | weechat-822ae765435824650ae8fe6f538489d1090c044f.zip |
core: fix crash in child process of hook_process_hashtable when arguments are given in hashtable and that execvp() failed
Diffstat (limited to 'src')
-rw-r--r-- | src/core/wee-hook.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/core/wee-hook.c b/src/core/wee-hook.c index ffe96864e..5dd62f98d 100644 --- a/src/core/wee-hook.c +++ b/src/core/wee-hook.c @@ -1414,7 +1414,7 @@ void hook_process_child (struct t_hook *hook_process) { char **exec_args, str_arg[64]; - const char *ptr_url; + const char *ptr_url, *ptr_arg; int rc, i, num_args; /* @@ -1464,7 +1464,9 @@ hook_process_child (struct t_hook *hook_process) while (1) { snprintf (str_arg, sizeof (str_arg), "arg%d", num_args + 1); - if (!hashtable_has_key (HOOK_PROCESS(hook_process, options), str_arg)) + ptr_arg = hashtable_get (HOOK_PROCESS(hook_process, options), + str_arg); + if (!ptr_arg) break; num_args++; } @@ -1479,12 +1481,13 @@ hook_process_child (struct t_hook *hook_process) exec_args = malloc ((num_args + 2) * sizeof (exec_args[0])); if (exec_args) { - exec_args[0] = HOOK_PROCESS(hook_process, command); + exec_args[0] = strdup (HOOK_PROCESS(hook_process, command)); for (i = 1; i <= num_args; i++) { snprintf (str_arg, sizeof (str_arg), "arg%d", i); - exec_args[i] = (char *)hashtable_get (HOOK_PROCESS(hook_process, options), - str_arg); + ptr_arg = hashtable_get (HOOK_PROCESS(hook_process, options), + str_arg); + exec_args[i] = (ptr_arg) ? strdup (ptr_arg) : NULL; } exec_args[num_args + 1] = NULL; } |