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
{
position_--;
--position_;
mapnik::fill(*position_, 0); // fill with transparent colour
}
return *position_;
}
bool in_range() const
{
return (position_ != buffers_.end());
}
void pop()
{
if (position_ != buffers_.end())
{
position_++;
}
// ^ ensure irator is not out-of-range
// prior calling this method
++position_;
}
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());
}
if (&current_buffer == &internal_buffers_.top())
if (internal_buffers_.in_range()
&& &current_buffer == &internal_buffers_.top())
{
internal_buffers_.pop();
}