diff --git a/include/drawtypes/progressbar.hpp b/include/drawtypes/progressbar.hpp index 1f99d1e8..5d3e25ab 100644 --- a/include/drawtypes/progressbar.hpp +++ b/include/drawtypes/progressbar.hpp @@ -78,13 +78,14 @@ 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(perc, m_colors.size() - 1); - m_fill->m_foreground = m_colors[color]; + 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); }