diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2017-03-18 15:16:32 +0100 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2017-03-25 14:19:48 +0100 |
commit | 196319170043fddfd701c5f1014be1c058fc5597 (patch) | |
tree | 225b339258c8be636dbc50d5d83f53ad172559c2 /src | |
parent | d31e4f1d9ac3820ac47550354ebff0b15ec4d143 (diff) | |
download | weechat-196319170043fddfd701c5f1014be1c058fc5597.zip |
core: prevent infinite loop in evaluation of expression with extra_vars_eval
When extra variables are evaluated, to prevent infinite loop if the evaluated
variable is calling itself, it is removed from hashtable "extra_vars" before
evaluation.
Diffstat (limited to 'src')
-rw-r--r-- | src/core/wee-eval.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/core/wee-eval.c b/src/core/wee-eval.c index 91d3bc37a..c54458261 100644 --- a/src/core/wee-eval.c +++ b/src/core/wee-eval.c @@ -345,10 +345,17 @@ eval_replace_vars_cb (void *data, const char *text) { if (extra_vars_eval) { - return eval_replace_vars (ptr_value, pointers, - extra_vars, extra_vars_eval, - prefix, suffix, - eval_regex); + tmp = strdup (ptr_value); + if (!tmp) + return NULL; + hashtable_remove (extra_vars, text); + value = eval_replace_vars (tmp, pointers, + extra_vars, extra_vars_eval, + prefix, suffix, + eval_regex); + hashtable_set (extra_vars, text, tmp); + free (tmp); + return value; } else { |