From a0f5111436821b890bbd64f7a74dd5e410cc9a8f Mon Sep 17 00:00:00 2001 From: rlar Date: Fri, 11 Mar 2016 22:37:25 +0100 Subject: [PATCH] parser/lexical.c, #2/10, move the `wlist' and `cw' resetting nearer to the `goto nloop' --- src/frontend/parser/lexical.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/frontend/parser/lexical.c b/src/frontend/parser/lexical.c index 4e4140489..6ea194620 100644 --- a/src/frontend/parser/lexical.c +++ b/src/frontend/parser/lexical.c @@ -124,7 +124,7 @@ cp_lexer(char *string) { int c, d; int i, j; - wordlist *wlist = NULL, *cw = NULL; + wordlist *wlist, *cw; char buf[NEW_BSIZE_SP], linebuf[NEW_BSIZE_SP]; int paren; @@ -137,6 +137,7 @@ cp_lexer(char *string) prompt(); } + wlist = cw = NULL; nloop: wlist = cw = NULL; i = 0; @@ -188,12 +189,14 @@ nloop: c = '\n'; if ((c == cp_hash) && !cp_interactive && (j == 1)) { - wl_free(wlist); - wlist = cw = NULL; - if (string) + if (string) { + wl_free(wlist); return NULL; + } while (((c = cp_readchar(&string, cp_inp_cur)) != '\n') && (c != EOF)) ; + wl_free(wlist); + wlist = cw = NULL; goto nloop; } @@ -271,7 +274,6 @@ nloop: // cp_ccom doesn't mess wlist, read only access to wlist->wl_word cp_ccom(wlist, buf, FALSE); - wl_free(wlist); (void) fputc('\r', cp_out); prompt(); for (j = 0; linebuf[j]; j++) @@ -280,6 +282,7 @@ nloop: #else fputc(linebuf[j], cp_out); /* But you can't edit */ #endif + wl_free(wlist); wlist = cw = NULL; goto nloop; }