Created
January 8, 2013 03:42
-
-
Save springmeyer/4480986 to your computer and use it in GitHub Desktop.
fix agg overflows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/deps/agg/include/agg_array.h b/deps/agg/include/agg_array.h | |
index 8d56683..9c7a447 100644 | |
--- a/deps/agg/include/agg_array.h | |
+++ b/deps/agg/include/agg_array.h | |
@@ -513,7 +513,7 @@ namespace agg | |
//------------------------------------------------------------------------ | |
template<class T, unsigned S> pod_bvector<T, S>::~pod_bvector() | |
{ | |
- if(m_num_blocks) | |
+ if(m_num_blocks > 0) | |
{ | |
T** blk = m_blocks + m_num_blocks - 1; | |
while(m_num_blocks--) | |
diff --git a/deps/agg/include/agg_rasterizer_cells_aa.h b/deps/agg/include/agg_rasterizer_cells_aa.h | |
index 4e1c62a..f35b884 100755 | |
--- a/deps/agg/include/agg_rasterizer_cells_aa.h | |
+++ b/deps/agg/include/agg_rasterizer_cells_aa.h | |
@@ -663,14 +663,17 @@ namespace agg | |
cell_type* cell_ptr; | |
unsigned nb = m_num_cells >> cell_block_shift; | |
unsigned i; | |
- while(nb--) | |
+ if (nb > 0) | |
{ | |
- cell_ptr = *block_ptr++; | |
- i = cell_block_size; | |
- while(i--) | |
+ while(nb--) | |
{ | |
- m_sorted_y[cell_ptr->y - m_min_y].start++; | |
- ++cell_ptr; | |
+ cell_ptr = *block_ptr++; | |
+ i = cell_block_size; | |
+ while(i--) | |
+ { | |
+ m_sorted_y[cell_ptr->y - m_min_y].start++; | |
+ ++cell_ptr; | |
+ } | |
} | |
} | |
diff --git a/deps/agg/include/agg_rasterizer_scanline_aa.h b/deps/agg/include/agg_rasterizer_scanline_aa.h | |
index 77bc41b..544f76c 100644 | |
--- a/deps/agg/include/agg_rasterizer_scanline_aa.h | |
+++ b/deps/agg/include/agg_rasterizer_scanline_aa.h | |
@@ -259,7 +259,8 @@ namespace agg | |
if(area) | |
{ | |
- alpha = calculate_alpha((cover << (poly_subpixel_shift + 1)) - area); | |
+ int cover_shift = cover << (poly_subpixel_shift + 1); | |
+ alpha = calculate_alpha(cover_shift - area); | |
if(alpha) | |
{ | |
sl.add_cell(x, alpha); | |
@@ -269,7 +270,8 @@ namespace agg | |
if(num_cells && cur_cell->x > x) | |
{ | |
- alpha = calculate_alpha(cover << (poly_subpixel_shift + 1)); | |
+ int cover_shift = cover << (poly_subpixel_shift + 1); | |
+ alpha = calculate_alpha(cover_shift); | |
if(alpha) | |
{ | |
sl.add_span(x, cur_cell->x - x, alpha); | |
diff --git a/deps/agg/include/agg_rendering_buffer.h b/deps/agg/include/agg_rendering_buffer.h | |
index e43899e..14ed414 100644 | |
--- a/deps/agg/include/agg_rendering_buffer.h | |
+++ b/deps/agg/include/agg_rendering_buffer.h | |
@@ -186,7 +186,7 @@ namespace agg | |
T** rows = &m_rows[0]; | |
- while(height--) | |
+ while(height > 0 && height--) | |
{ | |
*rows++ = row_ptr; | |
row_ptr += stride; | |
diff --git a/include/mapnik/vertex_vector.hpp b/include/mapnik/vertex_vector.hpp | |
index 44fbd78..12c0f92 100644 | |
--- a/include/mapnik/vertex_vector.hpp | |
+++ b/include/mapnik/vertex_vector.hpp | |
@@ -77,7 +77,7 @@ public: | |
if ( num_blocks_ ) | |
{ | |
coord_type** vertices=vertices_ + num_blocks_ - 1; | |
- while ( num_blocks_-- ) | |
+ while ( num_blocks_> 0 && num_blocks_-- ) | |
{ | |
::operator delete(*vertices); | |
--vertices; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment