From: Kevin McCarthy Date: Thu, 18 Jan 2018 02:57:49 +0000 (-0800) Subject: Fix a couple memory leaks in pattern.c X-Git-Tag: neomutt-20180223~40 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=16efc279b03200d1b59ca09542b3f5ef9240ee39;p=neomutt Fix a couple memory leaks in pattern.c BUFFER.data was not being freed in a couple cases. The pattern and simple search were not being freed if imap_search() failed. --- diff --git a/pattern.c b/pattern.c index a1a4afb8f..a71027354 100644 --- a/pattern.c +++ b/pattern.c @@ -1892,6 +1892,7 @@ int mutt_pattern_func(int op, char *prompt) struct Pattern *pat = NULL; char buf[LONG_STRING] = "", *simple = NULL; struct Buffer err; + int rc = -1; struct Progress progress; mutt_str_strfcpy(buf, NONULL(Context->pattern), sizeof(buf)); @@ -1910,15 +1911,13 @@ int mutt_pattern_func(int op, char *prompt) pat = mutt_pattern_comp(buf, MUTT_FULL_MSG, &err); if (!pat) { - FREE(&simple); mutt_error("%s", err.data); - FREE(&err.data); - return -1; + goto bail; } #ifdef USE_IMAP if (Context->magic == MUTT_IMAP && imap_search(Context, pat) < 0) - return -1; + goto bail; #endif mutt_progress_init(&progress, _("Executing command on matching messages..."), @@ -1997,11 +1996,15 @@ int mutt_pattern_func(int op, char *prompt) Context->limit_pattern = mutt_pattern_comp(buf, MUTT_FULL_MSG, &err); } } + + rc = 0; + +bail: FREE(&simple); mutt_pattern_free(&pat); FREE(&err.data); - return 0; + return rc; } int mutt_search_command(int cur, int op) @@ -2051,6 +2054,7 @@ int mutt_search_command(int cur, int op) LastSearch[0] = '\0'; return -1; } + FREE(&err.data); mutt_clear_error(); } }