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.

drh 2025-02-27 12:22 trunk
Commit 8ccedde4c6b4bdd55cd2516ebb8c7fc9b7539545db69cd500dcee08b23042086
1 file changed +1
--- src/comformat.c
+++ src/comformat.c
@@ -220,10 +220,11 @@
220220
int maxChars, /* [in] Optimization hint to abort before space found. */
221221
int *sumWidth /* [out] Summated width of all characters to next space. */
222222
){
223223
int cchUTF8, utf32, wcwidth = 0;
224224
int nextIndex = index;
225
+ if( zLine[index]==0 ) return index;
225226
for(;;){
226227
char_info_utf8(&zLine[nextIndex],&cchUTF8,&utf32);
227228
nextIndex += cchUTF8;
228229
wcwidth += cli_wcwidth(utf32);
229230
if( zLine[nextIndex]==0 || fossil_isspace(zLine[nextIndex]) ||
230231
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button