Fossil SCM
Fix a bug in comment_print() discovered by the fuzzer enhancement of the previous check-in. This bug has existed for a long time and is not the result of recent changes.
Commit
8ccedde4c6b4bdd55cd2516ebb8c7fc9b7539545db69cd500dcee08b23042086
Parent
8639f9b2d52aa4c…
1 file changed
+1
+1
| --- src/comformat.c | ||
| +++ src/comformat.c | ||
| @@ -220,10 +220,11 @@ | ||
| 220 | 220 | int maxChars, /* [in] Optimization hint to abort before space found. */ |
| 221 | 221 | int *sumWidth /* [out] Summated width of all characters to next space. */ |
| 222 | 222 | ){ |
| 223 | 223 | int cchUTF8, utf32, wcwidth = 0; |
| 224 | 224 | int nextIndex = index; |
| 225 | + if( zLine[index]==0 ) return index; | |
| 225 | 226 | for(;;){ |
| 226 | 227 | char_info_utf8(&zLine[nextIndex],&cchUTF8,&utf32); |
| 227 | 228 | nextIndex += cchUTF8; |
| 228 | 229 | wcwidth += cli_wcwidth(utf32); |
| 229 | 230 | if( zLine[nextIndex]==0 || fossil_isspace(zLine[nextIndex]) || |
| 230 | 231 |
| --- src/comformat.c | |
| +++ src/comformat.c | |
| @@ -220,10 +220,11 @@ | |
| 220 | int maxChars, /* [in] Optimization hint to abort before space found. */ |
| 221 | int *sumWidth /* [out] Summated width of all characters to next space. */ |
| 222 | ){ |
| 223 | int cchUTF8, utf32, wcwidth = 0; |
| 224 | int nextIndex = index; |
| 225 | for(;;){ |
| 226 | char_info_utf8(&zLine[nextIndex],&cchUTF8,&utf32); |
| 227 | nextIndex += cchUTF8; |
| 228 | wcwidth += cli_wcwidth(utf32); |
| 229 | if( zLine[nextIndex]==0 || fossil_isspace(zLine[nextIndex]) || |
| 230 |
| --- src/comformat.c | |
| +++ src/comformat.c | |
| @@ -220,10 +220,11 @@ | |
| 220 | int maxChars, /* [in] Optimization hint to abort before space found. */ |
| 221 | int *sumWidth /* [out] Summated width of all characters to next space. */ |
| 222 | ){ |
| 223 | int cchUTF8, utf32, wcwidth = 0; |
| 224 | int nextIndex = index; |
| 225 | if( zLine[index]==0 ) return index; |
| 226 | for(;;){ |
| 227 | char_info_utf8(&zLine[nextIndex],&cchUTF8,&utf32); |
| 228 | nextIndex += cchUTF8; |
| 229 | wcwidth += cli_wcwidth(utf32); |
| 230 | if( zLine[nextIndex]==0 || fossil_isspace(zLine[nextIndex]) || |
| 231 |