summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2018-06-11 23:03:02 +0200
committerSébastien Helleu <flashcode@flashtux.org>2018-06-11 23:03:02 +0200
commitdc12f6bef0dea415e0c7403670b2e46960a95424 (patch)
treef5772fe5c641be607329f0576cbc35d74c22bbcc /src
parentc1f125cc6fcc565a4de8bee61f5c40c27e9310dd (diff)
downloadweechat-dc12f6bef0dea415e0c7403670b2e46960a95424.zip
fset: fix crash when applying filters after closing the fset buffer (closes #1204)
Diffstat (limited to 'src')
-rw-r--r--src/core/wee-eval.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/core/wee-eval.c b/src/core/wee-eval.c
index 149344975..29ffd2748 100644
--- a/src/core/wee-eval.c
+++ b/src/core/wee-eval.c
@@ -1235,6 +1235,7 @@ eval_expression (const char *expr, struct t_hashtable *pointers,
{
struct t_eval_context eval_context;
int condition, rc, pointers_allocated, regex_allocated;
+ int ptr_window_added, ptr_buffer_added;
char *value;
const char *default_prefix = EVAL_DEFAULT_PREFIX;
const char *default_suffix = EVAL_DEFAULT_SUFFIX;
@@ -1250,6 +1251,8 @@ eval_expression (const char *expr, struct t_hashtable *pointers,
regex_allocated = 0;
regex = NULL;
regex_replace = NULL;
+ ptr_window_added = 0;
+ ptr_buffer_added = 0;
if (pointers)
{
@@ -1283,12 +1286,18 @@ eval_expression (const char *expr, struct t_hashtable *pointers,
if (gui_current_window)
{
if (!hashtable_has_key (pointers, "window"))
+ {
hashtable_set (pointers, "window", gui_current_window);
+ ptr_window_added = 1;
+ }
if (!hashtable_has_key (pointers, "buffer"))
{
window = (struct t_gui_window *)hashtable_get (pointers, "window");
if (window)
+ {
hashtable_set (pointers, "buffer", window->buffer);
+ ptr_buffer_added = 1;
+ }
}
}
@@ -1366,7 +1375,16 @@ eval_expression (const char *expr, struct t_hashtable *pointers,
}
if (pointers_allocated)
+ {
hashtable_free (pointers);
+ }
+ else
+ {
+ if (ptr_window_added)
+ hashtable_remove (pointers, "window");
+ if (ptr_buffer_added)
+ hashtable_remove (pointers, "buffer");
+ }
if (regex && regex_allocated)
{
regfree (regex);