diff --git a/src/frontend/parser/lexical.c b/src/frontend/parser/lexical.c index 224949695..b9d77df29 100644 --- a/src/frontend/parser/lexical.c +++ b/src/frontend/parser/lexical.c @@ -185,6 +185,18 @@ gotchar: if (i) { buf[i] = '\0'; cw->wl_word = copy(buf); + // assumption: cw != NULL and cw->wl_next == NULL + cw->wl_next = wl_cons(NULL, NULL); + cw->wl_next->wl_prev = cw; + cw = cw->wl_next; + // note: we can overwrite buf and i here + // they won't be accessed any more (see `goto done') + bzero(buf, NEW_BSIZE_SP); + i = 0; + // cw->wl_prev is the recent cw + // thus this wl_next has been NULL per assumtion vrom above + cw->wl_prev->wl_next = NULL; + tfree(cw); } else { if (cw->wl_prev) { cw->wl_prev->wl_next = NULL;