Fossil SCM

An extra long diff may occur in side-by-side or html mode as discussed in [forum post 49cc60131b](https://fossil-scm.org/forum/forumpost/49cc60131b). When enumerating mxr triples, looping over multiple triples may exceed mxr.

preben 2023-11-14 19:03 trunk
Commit 3c9472e56b7d8e021dc07b7de47377c1cdce195030e02423e620fa6868cda954
1 file changed +1 -1
+1 -1
--- src/diff.c
+++ src/diff.c
@@ -2223,11 +2223,11 @@
22232223
mxr = p->nEdit;
22242224
while( mxr>2 && R[mxr-1]==0 && R[mxr-2]==0 ){ mxr -= 3; }
22252225
22262226
for(r=0; r<mxr; r += 3*nr){
22272227
/* Figure out how many triples to show in a single block */
2228
- for(nr=1; R[r+nr*3]>0 && R[r+nr*3]<(int)nContext*2; nr++){}
2228
+ for(nr=1; 3*nr<mxr && R[r+nr*3]>0 && R[r+nr*3]<(int)nContext*2; nr++){}
22292229
22302230
/* If there is a regex, skip this block (generate no diff output)
22312231
** if the regex matches or does not match both insert and delete.
22322232
** Only display the block if one side matches but the other side does
22332233
** not.
22342234
--- src/diff.c
+++ src/diff.c
@@ -2223,11 +2223,11 @@
2223 mxr = p->nEdit;
2224 while( mxr>2 && R[mxr-1]==0 && R[mxr-2]==0 ){ mxr -= 3; }
2225
2226 for(r=0; r<mxr; r += 3*nr){
2227 /* Figure out how many triples to show in a single block */
2228 for(nr=1; R[r+nr*3]>0 && R[r+nr*3]<(int)nContext*2; nr++){}
2229
2230 /* If there is a regex, skip this block (generate no diff output)
2231 ** if the regex matches or does not match both insert and delete.
2232 ** Only display the block if one side matches but the other side does
2233 ** not.
2234
--- src/diff.c
+++ src/diff.c
@@ -2223,11 +2223,11 @@
2223 mxr = p->nEdit;
2224 while( mxr>2 && R[mxr-1]==0 && R[mxr-2]==0 ){ mxr -= 3; }
2225
2226 for(r=0; r<mxr; r += 3*nr){
2227 /* Figure out how many triples to show in a single block */
2228 for(nr=1; 3*nr<mxr && R[r+nr*3]>0 && R[r+nr*3]<(int)nContext*2; nr++){}
2229
2230 /* If there is a regex, skip this block (generate no diff output)
2231 ** if the regex matches or does not match both insert and delete.
2232 ** Only display the block if one side matches but the other side does
2233 ** not.
2234

Keyboard Shortcuts

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