Fossil SCM

When diffing long sequences, the product of their lengths can overflow to a negative number, triggering optimalLCS() which is very expensive. Prevent this overflow. See [https://fossil-scm.org/forum/forumpost/5f9365f9fe] for discussion.

andygoth 2020-08-19 13:51 trunk
Commit e2b7dca948da84b7718ab5ddc576b45f4b19f37b1aeb0da0371ebdb10f6c7c47
1 file changed +1 -1
+1 -1
--- src/diff.c
+++ src/diff.c
@@ -1566,11 +1566,11 @@
15661566
iSYp = iSY;
15671567
iEXp = iEX;
15681568
iEYp = iEY;
15691569
}
15701570
}
1571
- if( iSXb==iEXb && (iE1-iS1)*(iE2-iS2)<400 ){
1571
+ if( iSXb==iEXb && (sqlite3_int64)(iE1-iS1)*(iE2-iS2)<400 ){
15721572
/* If no common sequence is found using the hashing heuristic and
15731573
** the input is not too big, use the expensive exact solution */
15741574
optimalLCS(p, iS1, iE1, iS2, iE2, piSX, piEX, piSY, piEY);
15751575
}else{
15761576
*piSX = iSXb;
15771577
--- src/diff.c
+++ src/diff.c
@@ -1566,11 +1566,11 @@
1566 iSYp = iSY;
1567 iEXp = iEX;
1568 iEYp = iEY;
1569 }
1570 }
1571 if( iSXb==iEXb && (iE1-iS1)*(iE2-iS2)<400 ){
1572 /* If no common sequence is found using the hashing heuristic and
1573 ** the input is not too big, use the expensive exact solution */
1574 optimalLCS(p, iS1, iE1, iS2, iE2, piSX, piEX, piSY, piEY);
1575 }else{
1576 *piSX = iSXb;
1577
--- src/diff.c
+++ src/diff.c
@@ -1566,11 +1566,11 @@
1566 iSYp = iSY;
1567 iEXp = iEX;
1568 iEYp = iEY;
1569 }
1570 }
1571 if( iSXb==iEXb && (sqlite3_int64)(iE1-iS1)*(iE2-iS2)<400 ){
1572 /* If no common sequence is found using the hashing heuristic and
1573 ** the input is not too big, use the expensive exact solution */
1574 optimalLCS(p, iS1, iE1, iS2, iE2, piSX, piEX, piSY, piEY);
1575 }else{
1576 *piSX = iSXb;
1577

Keyboard Shortcuts

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