Fossil SCM
Ensure the line buffer for the legacy comment printing algorithm can hold maximum-length UTF-8 sequences.
Commit
29d3a2ed4ee03c7f7ba222b7f2fddfa27c5cd823
Parent
b029ed2222b0b80…
1 file changed
+3
-2
+3
-2
| --- src/comformat.c | ||
| +++ src/comformat.c | ||
| @@ -322,12 +322,13 @@ | ||
| 322 | 322 | } |
| 323 | 323 | if( zText==0 ) zText = "(NULL)"; |
| 324 | 324 | if( maxChars<=0 ){ |
| 325 | 325 | maxChars = strlen(zText); |
| 326 | 326 | } |
| 327 | - if( maxChars >= (sizeof(zBuffer)) ){ | |
| 328 | - zBuf = fossil_malloc(maxChars+1); | |
| 327 | + /* Ensure the buffer can hold the longest-possible UTF-8 sequences. */ | |
| 328 | + if( maxChars >= (sizeof(zBuffer)/4-1) ){ | |
| 329 | + zBuf = fossil_malloc(maxChars*4+1); | |
| 329 | 330 | }else{ |
| 330 | 331 | zBuf = zBuffer; |
| 331 | 332 | } |
| 332 | 333 | for(;;){ |
| 333 | 334 | while( fossil_isspace(zText[0]) ){ zText++; } |
| 334 | 335 |
| --- src/comformat.c | |
| +++ src/comformat.c | |
| @@ -322,12 +322,13 @@ | |
| 322 | } |
| 323 | if( zText==0 ) zText = "(NULL)"; |
| 324 | if( maxChars<=0 ){ |
| 325 | maxChars = strlen(zText); |
| 326 | } |
| 327 | if( maxChars >= (sizeof(zBuffer)) ){ |
| 328 | zBuf = fossil_malloc(maxChars+1); |
| 329 | }else{ |
| 330 | zBuf = zBuffer; |
| 331 | } |
| 332 | for(;;){ |
| 333 | while( fossil_isspace(zText[0]) ){ zText++; } |
| 334 |
| --- src/comformat.c | |
| +++ src/comformat.c | |
| @@ -322,12 +322,13 @@ | |
| 322 | } |
| 323 | if( zText==0 ) zText = "(NULL)"; |
| 324 | if( maxChars<=0 ){ |
| 325 | maxChars = strlen(zText); |
| 326 | } |
| 327 | /* Ensure the buffer can hold the longest-possible UTF-8 sequences. */ |
| 328 | if( maxChars >= (sizeof(zBuffer)/4-1) ){ |
| 329 | zBuf = fossil_malloc(maxChars*4+1); |
| 330 | }else{ |
| 331 | zBuf = zBuffer; |
| 332 | } |
| 333 | for(;;){ |
| 334 | while( fossil_isspace(zText[0]) ){ zText++; } |
| 335 |