diff options
author | Steve Bennett <steveb@workware.net.au> | 2011-05-26 15:01:21 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2011-05-26 15:01:21 +1000 |
commit | 48f610a34db941af2c689b18c84ca7fd57e2c6d2 (patch) | |
tree | c6af002df10590c4620c029ae0d090e644482935 | |
parent | 4a62d315d05f6b020c9050be4b65b90864119d39 (diff) | |
download | jimtcl-48f610a34db941af2c689b18c84ca7fd57e2c6d2.zip jimtcl-48f610a34db941af2c689b18c84ca7fd57e2c6d2.tar.gz jimtcl-48f610a34db941af2c689b18c84ca7fd57e2c6d2.tar.bz2 |
Fix an infinite loop in subst
If a null byte is encountered
Signed-off-by: Steve Bennett <steveb@workware.net.au>
-rw-r--r-- | jim.c | 2 | ||||
-rw-r--r-- | regtest.tcl | 5 |
2 files changed, 6 insertions, 1 deletions
@@ -10151,7 +10151,7 @@ static int JimParseSubstStr(struct JimParserCtx *pc) { pc->tstart = pc->p; pc->tline = pc->linenr; - while (*pc->p && *pc->p != '$' && *pc->p != '[') { + while (pc->len && *pc->p != '$' && *pc->p != '[') { if (*pc->p == '\\' && pc->len > 1) { pc->p++; pc->len--; diff --git a/regtest.tcl b/regtest.tcl index 632df73..49a3d53 100644 --- a/regtest.tcl +++ b/regtest.tcl @@ -130,6 +130,11 @@ proc a {} { global ::blah; set ::blah test } a puts "TEST 20 PASSED" +# REGTEST 21 +# 26 May 2011 - infinite loop with null byte in subst +subst "abc\0def" +puts "TEST 21 PASSED" + # TAKE THE FOLLOWING puts AS LAST LINE puts "--- ALL TESTS PASSED ---" |