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.

drh 2014-01-11 20:39 trunk
Commit 37ffaaa91162bd5ab97906a5324e4d01e03c8df6
1 file changed +2 -2
+2 -2
--- src/diff.c
+++ src/diff.c
@@ -803,11 +803,11 @@
803803
p->zStart = zClassChng;
804804
}
805805
p->iStart2 = nPrefix + aLCS[1];
806806
p->iEnd2 = nLeft - nSuffix;
807807
p->zStart2 = aLCS[3]==nRightDiff ? zClassRm : zClassChng;
808
- sbsSimplifyLine(p, zLeft+nPrefix);
808
+ sbsSimplifyLine(p, zLeft);
809809
sbsWriteText(p, pLeft, SBS_TXTA);
810810
sbsWriteMarker(p, " | ", "|");
811811
sbsWriteLineno(p, lnRight, SBS_LNB);
812812
p->iStart = nPrefix;
813813
p->iEnd = nPrefix + aLCS[2];
@@ -818,11 +818,11 @@
818818
p->zStart = zClassChng;
819819
}
820820
p->iStart2 = nPrefix + aLCS[3];
821821
p->iEnd2 = nRight - nSuffix;
822822
p->zStart2 = aLCS[1]==nLeftDiff ? zClassAdd : zClassChng;
823
- sbsSimplifyLine(p, zRight+nPrefix);
823
+ sbsSimplifyLine(p, zRight);
824824
sbsWriteText(p, pRight, SBS_TXTB);
825825
return;
826826
}
827827
828828
/* If all else fails, show a single big change between left and right */
829829
--- 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

Keyboard Shortcuts

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