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.
Commit
e2b7dca948da84b7718ab5ddc576b45f4b19f37b1aeb0da0371ebdb10f6c7c47
Parent
dc94ebc2cd9151c…
1 file changed
+1
-1
+1
-1
| --- src/diff.c | ||
| +++ src/diff.c | ||
| @@ -1566,11 +1566,11 @@ | ||
| 1566 | 1566 | iSYp = iSY; |
| 1567 | 1567 | iEXp = iEX; |
| 1568 | 1568 | iEYp = iEY; |
| 1569 | 1569 | } |
| 1570 | 1570 | } |
| 1571 | - if( iSXb==iEXb && (iE1-iS1)*(iE2-iS2)<400 ){ | |
| 1571 | + if( iSXb==iEXb && (sqlite3_int64)(iE1-iS1)*(iE2-iS2)<400 ){ | |
| 1572 | 1572 | /* If no common sequence is found using the hashing heuristic and |
| 1573 | 1573 | ** the input is not too big, use the expensive exact solution */ |
| 1574 | 1574 | optimalLCS(p, iS1, iE1, iS2, iE2, piSX, piEX, piSY, piEY); |
| 1575 | 1575 | }else{ |
| 1576 | 1576 | *piSX = iSXb; |
| 1577 | 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 && (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 |