Commits

Remi Collet committed eca37d6

fix hangs in gdImageAALine (bug int overflow can still occur, need improvment

Comments (0)

Files changed (1)

 			dx = x2 - x1;
 			dy = y2 - y1;
 		}
-		x = x1 << 16;
+		x = x1;
 		y = y1 << 16;
 		inc = (dy * 65536) / dx;
 		/* TBB: set the last pixel for consistency (<=) */
-		while ((x >> 16) <= x2) {
+		while (x <= x2) {
 			wstart = (y >> 16) - wid / 2;
 			for (w = wstart; w < wstart + wid; w++) {
-			    gdImageSetAAPixelColor(im, (x >> 16) , w , col , (y >> 8) & 0xFF);
-			    gdImageSetAAPixelColor(im, (x >> 16) , w + 1 , col, (~y >> 8) & 0xFF);
+			    gdImageSetAAPixelColor(im, x , w , col , (y >> 8) & 0xFF);
+			    gdImageSetAAPixelColor(im, x , w + 1 , col, (~y >> 8) & 0xFF);
 			}
-			x += (1 << 16);
+			x++;
 			y += inc;
 		}
 	} else {
 			dy = y2 - y1;
 		}
 		x = x1 << 16;
-		y = y1 << 16;
+		y = y1;
 		inc = (dx * 65536) / dy;
 		/* TBB: set the last pixel for consistency (<=) */
-		while ((y >> 16) <= y2) {
+		while (y <= y2) {
 			wstart = (x >> 16) - wid / 2;
 			for (w = wstart; w < wstart + wid; w++) {
-			    gdImageSetAAPixelColor(im, w , y >> 16  , col, (x >> 8) & 0xFF);
-			    gdImageSetAAPixelColor(im, w + 1, y >> 16, col, (~x >> 8) & 0xFF);
+			    gdImageSetAAPixelColor(im, w , y  , col, (x >> 8) & 0xFF);
+			    gdImageSetAAPixelColor(im, w + 1, y, col, (~x >> 8) & 0xFF);
 			}
 			x += inc;
-			y += (1 << 16);
+			y++;
 		}
 	}
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.