fix(progressbar): Add safety check

Fixes jaagr/lemonbuddy#132
This commit is contained in:
Michael Carlberg 2016-10-29 19:37:49 +02:00
parent 07b467cd38
commit c1be785be7

View File

@ -78,12 +78,13 @@ namespace drawtypes {
} else if (m_gradient) {
size_t color = 0;
for (size_t i = 0; i < fill_width; i++) {
if (i % m_colorstep == 0)
if (i % m_colorstep == 0 && color < m_colors.size())
m_fill->m_foreground = m_colors[color++];
m_builder->node(m_fill);
}
} else {
size_t color = math_util::percentage_to_value<size_t>(perc, m_colors.size() - 1);
if (color < m_colors.size())
m_fill->m_foreground = m_colors[color];
for (size_t i = 0; i < fill_width; i++) {
m_builder->node(m_fill);