Blame SOURCES/gd-sa1.patch

afb210
These issues were found by Coverity static analysis tool
afb210
afb210
Error: DEADCODE (CWE-561): [#def3]
afb210
gd-2.0.35/gd.c:3494: cond_cannot_single: Condition "dx == 0L", taking false branch. Now the value of "dx" cannot be equal to 0.
afb210
gd-2.0.35/gd.c:3502: cannot_single: At condition "dx == 0L", the value of "dx" cannot be equal to 0.
afb210
gd-2.0.35/gd.c:3502: dead_error_condition: The condition "dx == 0L" cannot be true.
afb210
gd-2.0.35/gd.c:3502: dead_error_line: Execution cannot reach this expression "dy == 0L" inside statement "if (dx == 0L && dy == 0L){
afb210
...".
afb210
afb210
Error: DEADCODE (CWE-561): [#def4]
afb210
gd-2.0.35/gd.c:1085: cond_cannot_single: Condition "dx == 0", taking false branch. Now the value of "dx" cannot be equal to 0.
afb210
gd-2.0.35/gd.c:1097: cannot_single: At condition "dx == 0", the value of "dx" cannot be equal to 0.
afb210
gd-2.0.35/gd.c:1097: dead_error_condition: The condition "dx == 0" cannot be true.
afb210
gd-2.0.35/gd.c:1097: dead_error_line: Execution cannot reach this expression "dy == 0" inside statement "if (dx == 0 && dy == 0){
afb210
  ...".
afb210
afb210
afb210
diff -up gd-2.0.35/gd.c.sa1 gd-2.0.35/gd.c
afb210
--- gd-2.0.35/gd.c.sa1	2012-12-05 16:23:09.289667430 +0100
afb210
+++ gd-2.0.35/gd.c	2012-12-05 16:30:41.634854587 +0100
afb210
@@ -1094,11 +1094,6 @@ BGD_DECLARE(void) gdImageLine (gdImagePt
afb210
     {
afb210
       /* More-or-less horizontal. use wid for vertical stroke */
afb210
       /* Doug Claar: watch out for NaN in atan2 (2.0.5) */
afb210
-      if ((dx == 0) && (dy == 0))
afb210
-	{
afb210
-	  wid = 1;
afb210
-	}
afb210
-      else
afb210
 	{
afb210
 	  /* 2.0.12: Michael Schwartz: divide rather than multiply;
afb210
 	     TBB: but watch out for /0! */
afb210
@@ -3490,6 +3485,12 @@ static void gdImageAALine (gdImagePtr im
afb210
 	dx = x2 - x1;
afb210
 	dy = y2 - y1;
afb210
 
afb210
+	if (dx == 0 && dy == 0) {
afb210
+		/* TBB: allow setting points */
afb210
+		gdImageSetAAPixelColor(im, x1, y1, col, 0xFF);
afb210
+		return;
afb210
+	}
afb210
+
afb210
 	/* Axis aligned lines */
afb210
 	if (dx == 0) {
afb210
 		gdImageVLine(im, x1, y1, y2, col);
afb210
@@ -3499,12 +3500,7 @@ static void gdImageAALine (gdImagePtr im
afb210
 		return;
afb210
 	}
afb210
 
afb210
-	if (dx == 0 && dy == 0) {
afb210
-		/* TBB: allow setting points */
afb210
-		gdImageSetAAPixelColor(im, x1, y1, col, 0xFF);
afb210
-		return;
afb210
-	}
afb210
-	else { 
afb210
+	{ 
afb210
 	    double ag; 
afb210
 	    if (abs(dy) < abs(dx))  
afb210
 		ag  = cos (atan2 (dy, dx));