From 611dc46d8b216c22f05604e8df6bee7aa59e5977 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Sun, 11 Oct 2015 20:46:55 +0300 Subject: Bug fix, invalid read in yylex. --- awkgram.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'awkgram.c') diff --git a/awkgram.c b/awkgram.c index 9ced0daf..845dbbef 100644 --- a/awkgram.c +++ b/awkgram.c @@ -142,8 +142,8 @@ const char *const ruletab[] = { static bool in_print = false; /* lexical scanning kludge for print */ static int in_parens = 0; /* lexical scanning kludge for print */ static int sub_counter = 0; /* array dimension counter for use in delete */ -static char *lexptr = NULL; /* pointer to next char during parsing */ -static char *lexend; +static char *lexptr; /* pointer to next char during parsing */ +static char *lexend; /* end of buffer */ static char *lexptr_begin; /* keep track of where we were for error msgs */ static char *lexeme; /* beginning of lexeme for debugging */ static bool lexeof; /* seen EOF for current source? */ @@ -4450,7 +4450,8 @@ yyerror(const char *m, ...) if (thisline == NULL) { cp = lexeme; if (*cp == '\n') { - cp--; + if (cp > lexptr_begin) + cp--; mesg = _("unexpected newline or end of string"); } for (; cp != lexptr_begin && *cp != '\n'; --cp) @@ -4461,6 +4462,8 @@ yyerror(const char *m, ...) } /* NL isn't guaranteed */ bp = lexeme; + if (bp < thisline) + bp = thisline + 1; while (bp < lexend && *bp && *bp != '\n') bp++; } else { -- cgit v1.2.3