From 37fa925871912835897acf379ad1cd9ecffee8c9 Mon Sep 17 00:00:00 2001 From: Jim Monte Date: Tue, 10 Dec 2019 15:22:19 -0500 Subject: [PATCH] Fixed memory leak when empty word found. --- src/frontend/control.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/frontend/control.c b/src/frontend/control.c index 27192b768..40f0f040c 100644 --- a/src/frontend/control.c +++ b/src/frontend/control.c @@ -648,11 +648,12 @@ cp_evloop(char *string) for (;;) { freewl = wlist = getcommand(string); - if (wlist == NULL) { /* End of file or end of user input. */ + if (wlist == NULL) { /* End of file or end of user input. */ if (cend[stackp] && cend[stackp]->co_parent && !string) { cp_resetcontrol(); continue; - } else { + } + else { return (0); } } @@ -669,12 +670,14 @@ cp_evloop(char *string) } /* Just a check... */ - for (ww = wlist; ww; ww = ww->wl_next) + for (ww = wlist; ww; ww = ww->wl_next) { if (!ww->wl_word) { fprintf(cp_err, "cp_evloop: Internal Error: NULL word pointer\n"); + wl_free(wlist); continue; } + } /* Add this to the control structure list. If cend->co_type is