From 89605e12fc2770394b2b81afb11275af0fbcf7d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Diego=20Aur=C3=A9lio=20Mesquita?= Date: Sun, 4 Feb 2018 21:38:23 -0200 Subject: [PATCH] If previous promp answer should not be used, clean it up. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marco Diego Aurélio Mesquita --- src/search.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/search.c b/src/search.c index 2d5e2cc1..adedf696 100644 --- a/src/search.c +++ b/src/search.c @@ -99,6 +99,12 @@ void search_init(bool replacing, bool keep_the_answer) static char *sofar = NULL; /* What the user has typed so far, before toggling something. */ + /* If we don't need the answer, clean it up. */ + if (!keep_the_answer && sofar != NULL) { + free(sofar); + sofar = NULL; + } + if (keep_the_answer) sofar = mallocstrcpy(sofar, answer); -- 2.11.0