fix dereferencing out-of-range iterator (caught by -fsanitize=undefined,integer) (#3867)

This commit is contained in:
Artem Pavlenko 2018-03-01 11:54:41 +01:00
parent 5b8b75e680
commit eb1a32eb79
2 changed files with 10 additions and 6 deletions

View file

@ -81,18 +81,21 @@ public:
} }
else else
{ {
position_--; --position_;
mapnik::fill(*position_, 0); // fill with transparent colour mapnik::fill(*position_, 0); // fill with transparent colour
} }
return *position_; return *position_;
} }
bool in_range() const
{
return (position_ != buffers_.end());
}
void pop() void pop()
{ {
if (position_ != buffers_.end()) // ^ ensure irator is not out-of-range
{ // prior calling this method
position_++; ++position_;
}
} }
T & top() const T & top() const

View file

@ -340,7 +340,8 @@ void agg_renderer<T0,T1>::end_style_processing(feature_type_style const& st)
-common_.t_.offset(), -common_.t_.offset(),
-common_.t_.offset()); -common_.t_.offset());
} }
if (&current_buffer == &internal_buffers_.top()) if (internal_buffers_.in_range()
&& &current_buffer == &internal_buffers_.top())
{ {
internal_buffers_.pop(); internal_buffers_.pop();
} }