Author: Brian Murray <brian@ubuntu.com>
Description: Avoid a crash caused by an infinite recursion when 
 drawing extremely long lines. (LP #344849)

diff -urNad agg-2.5+dfsg1~/include/agg_rasterizer_cells_aa.h agg-2.5+dfsg1/include/agg_rasterizer_cells_aa.h
--- agg-2.5+dfsg1~/include/agg_rasterizer_cells_aa.h	2007-10-10 15:06:16.000000000 -0700
+++ agg-2.5+dfsg1/include/agg_rasterizer_cells_aa.h	2009-04-02 18:34:07.000000000 -0700
@@ -333,6 +333,12 @@
         {
             int cx = (x1 + x2) >> 1;
             int cy = (y1 + y2) >> 1;
+
+            // Bail if values are so large they are likely to wrap
+            if ((std::abs(x1) >= std::numeric_limits<int>::max()/2) || (std::abs(y1) >= std::numeric_limits<int>::max()/2) ||
+                (std::abs(x2) >= std::numeric_limits<int>::max()/2) || (std::abs(y2) >= std::numeric_limits<int>::max()/2))
+                    return;
+
             line(x1, y1, cx, cy);
             line(cx, cy, x2, y2);
         }
