Fossil SCM

Fix a division by zero that can occur when trying to annotate a file that has never been changed.

drh 2013-05-28 10:53 trunk
Commit f370ab3948f68ba086699ad74eda9943df53ae21
1 file changed +1
+1
--- src/diff.c
+++ src/diff.c
@@ -2367,10 +2367,11 @@
23672367
** Return a color from a gradient.
23682368
*/
23692369
unsigned gradient_color(unsigned c1, unsigned c2, int n, int i){
23702370
unsigned c; /* Result color */
23712371
unsigned x1, x2;
2372
+ if( i==0 || n==0 ) return c1;
23722373
x1 = (c1>>16)&0xff;
23732374
x2 = (c2>>16)&0xff;
23742375
c = (x1*(n-i) + x2*i)/n<<16 & 0xff0000;
23752376
x1 = (c1>>8)&0xff;
23762377
x2 = (c2>>8)&0xff;
23772378
--- 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

Keyboard Shortcuts

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