From 5c6b8a4aa45f55d5288791942643ba5cf7d50395 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Wed, 18 Nov 2015 15:31:22 +0000 Subject: Only unget match[] if it has been used, ok sthen --- bin/ksh/lex.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'bin') diff --git a/bin/ksh/lex.c b/bin/ksh/lex.c index 029d8dc5340..177c06d2275 100644 --- a/bin/ksh/lex.c +++ b/bin/ksh/lex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lex.c,v 1.63 2015/11/12 04:04:31 mmcc Exp $ */ +/* $OpenBSD: lex.c,v 1.64 2015/11/18 15:31:21 nicm Exp $ */ /* * lexical analysis and source input @@ -193,7 +193,7 @@ yylex(int cf) c == '!') { char **replace = NULL; int get, i; - char match[200], *str = match; + char match[200] = { 0 }, *str = match; size_t mlen; c2 = getsc(); @@ -247,12 +247,13 @@ yylex(int cf) s->u.freeme = NULL; source = s; continue; - } else { + } else if (*match != '\0') { /* restore what followed the '!' */ mlen = strlen(match); for (i = mlen-1; i >= 0; i--) ungetsc(match[i]); - } + } else + ungetsc(c2); } if (c == '[' && (cf & (VARASN|ARRAYVAR))) { *wp = EOS; /* temporary */ -- cgit v1.2.3