diff options
author | Steve Bennett <steveb@workware.net.au> | 2010-10-16 10:04:58 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2010-10-20 10:09:22 +1000 |
commit | ad3f49ba9d88bb6bfb67b4cc3806736857151ab0 (patch) | |
tree | cf07e6a13341f74501d411abfb17b03edb638c5a | |
parent | 69970bfa0e20f1cd4cce8c5f1e0b497e16321272 (diff) | |
download | jimtcl-ad3f49ba9d88bb6bfb67b4cc3806736857151ab0.zip jimtcl-ad3f49ba9d88bb6bfb67b4cc3806736857151ab0.tar.gz jimtcl-ad3f49ba9d88bb6bfb67b4cc3806736857151ab0.tar.bz2 |
Fix a parse error on trailine newline
If a script contain [ with a trailing backslash,
the parser would crash. e.g.
. list [split \
Signed-off-by: Steve Bennett <steveb@workware.net.au>
-rw-r--r-- | jim.c | 9 |
1 files changed, 3 insertions, 6 deletions
@@ -1177,11 +1177,8 @@ static int JimParseCmd(struct JimParserCtx *pc) pc->tstart = ++pc->p; pc->len--; pc->tline = pc->linenr; - while (1) { - if (pc->len == 0) { - break; - } - else if (*pc->p == '[' && blevel == 0) { + while (pc->len) { + if (*pc->p == '[' && blevel == 0) { level++; } else if (*pc->p == ']' && blevel == 0) { @@ -1189,7 +1186,7 @@ static int JimParseCmd(struct JimParserCtx *pc) if (!level) break; } - else if (*pc->p == '\\') { + else if (*pc->p == '\\' && pc->len > 1) { pc->p++; pc->len--; if (*pc->p == '\n') |