aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2010-10-16 10:04:58 +1000
committerSteve Bennett <steveb@workware.net.au>2010-10-20 10:09:22 +1000
commitad3f49ba9d88bb6bfb67b4cc3806736857151ab0 (patch)
treecf07e6a13341f74501d411abfb17b03edb638c5a
parent69970bfa0e20f1cd4cce8c5f1e0b497e16321272 (diff)
downloadjimtcl-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.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/jim.c b/jim.c
index a6bf080..85f5990 100644
--- a/jim.c
+++ b/jim.c
@@ -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')