From a99dd7b00b82629caa32f277b18f3f768ee4173d Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Thu, 23 Nov 2023 11:55:57 +0100 Subject: [PATCH] Fixed a crash in GCodeViewer (SPE-2052, #11728) --- src/slic3r/GUI/GCodeViewer.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index 14743415c2..0ac5f4294a 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -492,9 +492,10 @@ void GCodeViewer::SequentialView::GCodeWindow::render(float top, float bottom, s const size_t ref_id = (i == 0) ? 0 : i - 1; const size_t first_line_id = (i == 0) ? *m_cache_range.min : - (*m_cache_range.min - 1 >= cumulative_lines_counts[ref_id]) ? *m_cache_range.min - cumulative_lines_counts[ref_id] : 1; - const size_t last_line_id = (*m_cache_range.max - 1 <= cumulative_lines_counts[i]) ? - (i == 0) ? *m_cache_range.max : *m_cache_range.max - cumulative_lines_counts[ref_id] : m_lines_ends[i].size() - 1; + (*m_cache_range.min > cumulative_lines_counts[ref_id]) ? *m_cache_range.min - cumulative_lines_counts[ref_id] : 1; + const size_t last_line_id = (*m_cache_range.max <= cumulative_lines_counts[i]) ? + (i == 0) ? *m_cache_range.max : *m_cache_range.max - cumulative_lines_counts[ref_id] : m_lines_ends[i].size(); + assert(last_line_id >= first_line_id); for (size_t j = first_line_id; j <= last_line_id; ++j) { const size_t begin = (j == 1) ? 0 : m_lines_ends[i][j - 2];