Fossil SCM
Fix a division by zero that can occur when trying to annotate a file that has never been changed.
Commit
f370ab3948f68ba086699ad74eda9943df53ae21
Parent
9f3fb6cb9814ad0…
1 file changed
+1
+1
| --- src/diff.c | ||
| +++ src/diff.c | ||
| @@ -2367,10 +2367,11 @@ | ||
| 2367 | 2367 | ** Return a color from a gradient. |
| 2368 | 2368 | */ |
| 2369 | 2369 | unsigned gradient_color(unsigned c1, unsigned c2, int n, int i){ |
| 2370 | 2370 | unsigned c; /* Result color */ |
| 2371 | 2371 | unsigned x1, x2; |
| 2372 | + if( i==0 || n==0 ) return c1; | |
| 2372 | 2373 | x1 = (c1>>16)&0xff; |
| 2373 | 2374 | x2 = (c2>>16)&0xff; |
| 2374 | 2375 | c = (x1*(n-i) + x2*i)/n<<16 & 0xff0000; |
| 2375 | 2376 | x1 = (c1>>8)&0xff; |
| 2376 | 2377 | x2 = (c2>>8)&0xff; |
| 2377 | 2378 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -2367,10 +2367,11 @@ | |
| 2367 | ** Return a color from a gradient. |
| 2368 | */ |
| 2369 | unsigned gradient_color(unsigned c1, unsigned c2, int n, int i){ |
| 2370 | unsigned c; /* Result color */ |
| 2371 | unsigned x1, x2; |
| 2372 | x1 = (c1>>16)&0xff; |
| 2373 | x2 = (c2>>16)&0xff; |
| 2374 | c = (x1*(n-i) + x2*i)/n<<16 & 0xff0000; |
| 2375 | x1 = (c1>>8)&0xff; |
| 2376 | x2 = (c2>>8)&0xff; |
| 2377 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -2367,10 +2367,11 @@ | |
| 2367 | ** Return a color from a gradient. |
| 2368 | */ |
| 2369 | unsigned gradient_color(unsigned c1, unsigned c2, int n, int i){ |
| 2370 | unsigned c; /* Result color */ |
| 2371 | unsigned x1, x2; |
| 2372 | if( i==0 || n==0 ) return c1; |
| 2373 | x1 = (c1>>16)&0xff; |
| 2374 | x2 = (c2>>16)&0xff; |
| 2375 | c = (x1*(n-i) + x2*i)/n<<16 & 0xff0000; |
| 2376 | x1 = (c1>>8)&0xff; |
| 2377 | x2 = (c2>>8)&0xff; |
| 2378 |