From 0d902c9f5c313a92bae667ab316082071c11009c Mon Sep 17 00:00:00 2001 From: Rubidium Date: Sun, 9 Mar 2025 23:02:50 +0100 Subject: [PATCH] Codefix: possible out-of-bounds array indexing --- src/gfx_layout_icu.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gfx_layout_icu.cpp b/src/gfx_layout_icu.cpp index 7821fc775c..d7ee97e7ce 100644 --- a/src/gfx_layout_icu.cpp +++ b/src/gfx_layout_icu.cpp @@ -443,11 +443,11 @@ std::unique_ptr ICUParagraphLayout::NextLine(int size_t index; if ((overflow_run->level & 1) == 0) { /* LTR */ - for (index = overflow_run->glyphs.size(); index > 0; index--) { - cur_width -= overflow_run->advance[index - 1]; + for (index = overflow_run->glyphs.size(); index > 0; /* nothing */) { + --index; + cur_width -= overflow_run->advance[index]; if (cur_width <= max_width) break; } - index--; } else { /* RTL */ for (index = 0; index < overflow_run->glyphs.size(); index++) {