diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2015-11-18 15:31:22 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2015-11-18 15:31:22 +0000 |
commit | 5c6b8a4aa45f55d5288791942643ba5cf7d50395 (patch) | |
tree | 9fbb47b481e627037fdebff34bcc39137ba814f1 /bin | |
parent | 366dc9ce8e54ed7ccd64bf8eae280439b4fd68df (diff) |
Only unget match[] if it has been used, ok sthen
Diffstat (limited to 'bin')
-rw-r--r-- | bin/ksh/lex.c | 9 |
1 files changed, 5 insertions, 4 deletions
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 */ |