diff --git a/ChangeLog.asciidoc b/ChangeLog.asciidoc index 5cbd340b1..50b88e4db 100644 --- a/ChangeLog.asciidoc +++ b/ChangeLog.asciidoc @@ -15,6 +15,7 @@ http://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes] == Version 0.4.4 (under dev) +* core: fix recursive calls to function eval_expression * core: mute all buffers by default in command /mute (replace option -all by -core) * core: save and restore mute state in command /mute (bug #41748) diff --git a/src/core/wee-eval.c b/src/core/wee-eval.c index 01243c198..23af934de 100644 --- a/src/core/wee-eval.c +++ b/src/core/wee-eval.c @@ -780,7 +780,7 @@ char * eval_expression (const char *expr, struct t_hashtable *pointers, struct t_hashtable *extra_vars, struct t_hashtable *options) { - int condition, rc; + int condition, rc, pointers_allocated; char *value; const char *prefix, *suffix, *default_prefix = "${", *default_suffix = "}"; const char *ptr_value; @@ -790,25 +790,21 @@ eval_expression (const char *expr, struct t_hashtable *pointers, return NULL; condition = 0; + pointers_allocated = 0; prefix = default_prefix; suffix = default_suffix; /* create hashtable pointers if it's NULL */ if (!pointers) { - if (eval_hashtable_pointers) - hashtable_remove_all (eval_hashtable_pointers); - else - { - eval_hashtable_pointers = hashtable_new (32, - WEECHAT_HASHTABLE_STRING, - WEECHAT_HASHTABLE_POINTER, - NULL, - NULL); - if (!eval_hashtable_pointers) - return NULL; - } - pointers = eval_hashtable_pointers; + pointers = hashtable_new (32, + WEECHAT_HASHTABLE_STRING, + WEECHAT_HASHTABLE_POINTER, + NULL, + NULL); + if (!pointers) + return NULL; + pointers_allocated = 1; } /* @@ -863,19 +859,8 @@ eval_expression (const char *expr, struct t_hashtable *pointers, value = eval_replace_vars (expr, pointers, extra_vars, prefix, suffix); } + if (pointers_allocated) + hashtable_free (pointers); + return value; } - -/* - * Frees all allocated data. - */ - -void -eval_end () -{ - if (eval_hashtable_pointers) - { - hashtable_free (eval_hashtable_pointers); - eval_hashtable_pointers = NULL; - } -} diff --git a/src/core/wee-eval.h b/src/core/wee-eval.h index 652cd0b91..7af69c265 100644 --- a/src/core/wee-eval.h +++ b/src/core/wee-eval.h @@ -52,6 +52,5 @@ extern char *eval_expression (const char *expr, struct t_hashtable *pointers, struct t_hashtable *extra_vars, struct t_hashtable *options); -extern void eval_end (); #endif /* __WEECHAT_EVAL_H */ diff --git a/src/core/weechat.c b/src/core/weechat.c index 675d97612..71cb3af7c 100644 --- a/src/core/weechat.c +++ b/src/core/weechat.c @@ -489,7 +489,6 @@ main (int argc, char *argv[]) gui_key_end (); /* remove all keys */ unhook_all (); /* remove all hooks */ hdata_end (); /* end hdata */ - eval_end (); /* end eval */ secure_end (); /* end secured data */ string_end (); /* end string */ weechat_shutdown (EXIT_SUCCESS, 0); /* quit WeeChat (oh no, why?) */