Fossil SCM
In thEvalLocal(), do not read the byte after the end of a script. When the last command of a script ran to its end, or the script ended with a semicolon, one more byte was examined; for the body of a TH1 procedure without parameters that byte is past the end of its allocation.
Commit
856b85ede27ef1a77f0fbbd6d51c21999503f02b29f7ec4e7aba2bab23e17612
Parent
4377c765a9c135e…
1 file changed
+2
-2
M
src/th.c
+2
-2
| --- src/th.c | ||
| +++ src/th.c | ||
| @@ -947,11 +947,11 @@ | ||
| 947 | 947 | zInput += nSpace; |
| 948 | 948 | nInput -= nSpace; |
| 949 | 949 | zFirst = zInput; |
| 950 | 950 | |
| 951 | 951 | /* Check for a comment. If found, skip to the end of the line. */ |
| 952 | - if( zInput[0]=='#' ){ | |
| 952 | + if( nInput>0 && zInput[0]=='#' ){ | |
| 953 | 953 | while( !thEndOfLine(zInput, nInput) ){ |
| 954 | 954 | zInput++; |
| 955 | 955 | nInput--; |
| 956 | 956 | } |
| 957 | 957 | continue; |
| @@ -958,11 +958,11 @@ | ||
| 958 | 958 | } |
| 959 | 959 | |
| 960 | 960 | /* Gobble up input a word at a time until the end of the command |
| 961 | 961 | ** (a semi-colon or end of line). |
| 962 | 962 | */ |
| 963 | - while( rc==TH_OK && *zInput!=';' && !thEndOfLine(zInput, nInput) ){ | |
| 963 | + while( rc==TH_OK && !thEndOfLine(zInput, nInput) && *zInput!=';' ){ | |
| 964 | 964 | int nWord=0; |
| 965 | 965 | thNextSpace(interp, zInput, nInput, &nSpace); |
| 966 | 966 | rc = thNextWord(interp, &zInput[nSpace], nInput-nSpace, &nWord, 1); |
| 967 | 967 | zInput += (nSpace+nWord); |
| 968 | 968 | nInput -= (nSpace+nWord); |
| 969 | 969 |
| --- src/th.c | |
| +++ src/th.c | |
| @@ -947,11 +947,11 @@ | |
| 947 | zInput += nSpace; |
| 948 | nInput -= nSpace; |
| 949 | zFirst = zInput; |
| 950 | |
| 951 | /* Check for a comment. If found, skip to the end of the line. */ |
| 952 | if( zInput[0]=='#' ){ |
| 953 | while( !thEndOfLine(zInput, nInput) ){ |
| 954 | zInput++; |
| 955 | nInput--; |
| 956 | } |
| 957 | continue; |
| @@ -958,11 +958,11 @@ | |
| 958 | } |
| 959 | |
| 960 | /* Gobble up input a word at a time until the end of the command |
| 961 | ** (a semi-colon or end of line). |
| 962 | */ |
| 963 | while( rc==TH_OK && *zInput!=';' && !thEndOfLine(zInput, nInput) ){ |
| 964 | int nWord=0; |
| 965 | thNextSpace(interp, zInput, nInput, &nSpace); |
| 966 | rc = thNextWord(interp, &zInput[nSpace], nInput-nSpace, &nWord, 1); |
| 967 | zInput += (nSpace+nWord); |
| 968 | nInput -= (nSpace+nWord); |
| 969 |
| --- src/th.c | |
| +++ src/th.c | |
| @@ -947,11 +947,11 @@ | |
| 947 | zInput += nSpace; |
| 948 | nInput -= nSpace; |
| 949 | zFirst = zInput; |
| 950 | |
| 951 | /* Check for a comment. If found, skip to the end of the line. */ |
| 952 | if( nInput>0 && zInput[0]=='#' ){ |
| 953 | while( !thEndOfLine(zInput, nInput) ){ |
| 954 | zInput++; |
| 955 | nInput--; |
| 956 | } |
| 957 | continue; |
| @@ -958,11 +958,11 @@ | |
| 958 | } |
| 959 | |
| 960 | /* Gobble up input a word at a time until the end of the command |
| 961 | ** (a semi-colon or end of line). |
| 962 | */ |
| 963 | while( rc==TH_OK && !thEndOfLine(zInput, nInput) && *zInput!=';' ){ |
| 964 | int nWord=0; |
| 965 | thNextSpace(interp, zInput, nInput, &nSpace); |
| 966 | rc = thNextWord(interp, &zInput[nSpace], nInput-nSpace, &nWord, 1); |
| 967 | zInput += (nSpace+nWord); |
| 968 | nInput -= (nSpace+nWord); |
| 969 |