Fossil SCM
Prevent buffer overruns when trying to do side-by-side diff alignment of lines that contain non-UTF8 characters and a prefix match.
Commit
37ffaaa91162bd5ab97906a5324e4d01e03c8df6
Parent
64fc6d15e5a3fdc…
1 file changed
+2
-2
+2
-2
| --- src/diff.c | ||
| +++ src/diff.c | ||
| @@ -803,11 +803,11 @@ | ||
| 803 | 803 | p->zStart = zClassChng; |
| 804 | 804 | } |
| 805 | 805 | p->iStart2 = nPrefix + aLCS[1]; |
| 806 | 806 | p->iEnd2 = nLeft - nSuffix; |
| 807 | 807 | p->zStart2 = aLCS[3]==nRightDiff ? zClassRm : zClassChng; |
| 808 | - sbsSimplifyLine(p, zLeft+nPrefix); | |
| 808 | + sbsSimplifyLine(p, zLeft); | |
| 809 | 809 | sbsWriteText(p, pLeft, SBS_TXTA); |
| 810 | 810 | sbsWriteMarker(p, " | ", "|"); |
| 811 | 811 | sbsWriteLineno(p, lnRight, SBS_LNB); |
| 812 | 812 | p->iStart = nPrefix; |
| 813 | 813 | p->iEnd = nPrefix + aLCS[2]; |
| @@ -818,11 +818,11 @@ | ||
| 818 | 818 | p->zStart = zClassChng; |
| 819 | 819 | } |
| 820 | 820 | p->iStart2 = nPrefix + aLCS[3]; |
| 821 | 821 | p->iEnd2 = nRight - nSuffix; |
| 822 | 822 | p->zStart2 = aLCS[1]==nLeftDiff ? zClassAdd : zClassChng; |
| 823 | - sbsSimplifyLine(p, zRight+nPrefix); | |
| 823 | + sbsSimplifyLine(p, zRight); | |
| 824 | 824 | sbsWriteText(p, pRight, SBS_TXTB); |
| 825 | 825 | return; |
| 826 | 826 | } |
| 827 | 827 | |
| 828 | 828 | /* If all else fails, show a single big change between left and right */ |
| 829 | 829 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -803,11 +803,11 @@ | |
| 803 | p->zStart = zClassChng; |
| 804 | } |
| 805 | p->iStart2 = nPrefix + aLCS[1]; |
| 806 | p->iEnd2 = nLeft - nSuffix; |
| 807 | p->zStart2 = aLCS[3]==nRightDiff ? zClassRm : zClassChng; |
| 808 | sbsSimplifyLine(p, zLeft+nPrefix); |
| 809 | sbsWriteText(p, pLeft, SBS_TXTA); |
| 810 | sbsWriteMarker(p, " | ", "|"); |
| 811 | sbsWriteLineno(p, lnRight, SBS_LNB); |
| 812 | p->iStart = nPrefix; |
| 813 | p->iEnd = nPrefix + aLCS[2]; |
| @@ -818,11 +818,11 @@ | |
| 818 | p->zStart = zClassChng; |
| 819 | } |
| 820 | p->iStart2 = nPrefix + aLCS[3]; |
| 821 | p->iEnd2 = nRight - nSuffix; |
| 822 | p->zStart2 = aLCS[1]==nLeftDiff ? zClassAdd : zClassChng; |
| 823 | sbsSimplifyLine(p, zRight+nPrefix); |
| 824 | sbsWriteText(p, pRight, SBS_TXTB); |
| 825 | return; |
| 826 | } |
| 827 | |
| 828 | /* If all else fails, show a single big change between left and right */ |
| 829 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -803,11 +803,11 @@ | |
| 803 | p->zStart = zClassChng; |
| 804 | } |
| 805 | p->iStart2 = nPrefix + aLCS[1]; |
| 806 | p->iEnd2 = nLeft - nSuffix; |
| 807 | p->zStart2 = aLCS[3]==nRightDiff ? zClassRm : zClassChng; |
| 808 | sbsSimplifyLine(p, zLeft); |
| 809 | sbsWriteText(p, pLeft, SBS_TXTA); |
| 810 | sbsWriteMarker(p, " | ", "|"); |
| 811 | sbsWriteLineno(p, lnRight, SBS_LNB); |
| 812 | p->iStart = nPrefix; |
| 813 | p->iEnd = nPrefix + aLCS[2]; |
| @@ -818,11 +818,11 @@ | |
| 818 | p->zStart = zClassChng; |
| 819 | } |
| 820 | p->iStart2 = nPrefix + aLCS[3]; |
| 821 | p->iEnd2 = nRight - nSuffix; |
| 822 | p->zStart2 = aLCS[1]==nLeftDiff ? zClassAdd : zClassChng; |
| 823 | sbsSimplifyLine(p, zRight); |
| 824 | sbsWriteText(p, pRight, SBS_TXTB); |
| 825 | return; |
| 826 | } |
| 827 | |
| 828 | /* If all else fails, show a single big change between left and right */ |
| 829 |