From 40e360e6404a580fecccc7b8781c553166460ed3 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 3 Aug 2024 22:23:48 +0200 Subject: [PATCH] Fixed a potential segfault in the text renderer --- src/laybasic/laybasic/layBitmap.cc | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/laybasic/laybasic/layBitmap.cc b/src/laybasic/laybasic/layBitmap.cc index 9a23bca4d..f82b5506e 100644 --- a/src/laybasic/laybasic/layBitmap.cc +++ b/src/laybasic/laybasic/layBitmap.cc @@ -293,16 +293,14 @@ Bitmap::fill_pattern (int y, int x, const uint32_t *pp, unsigned int stride, uns while (n > 0 && y >= 0) { - for (unsigned int s = 0; s < stride; ++s) { + for (unsigned int s = 0; s < stride; ++s, pp++) { - int x1 = x + s * 32; - - uint32_t p = *pp++; + uint32_t p = *pp; - if (x1 < 0) { - if (x1 <= -32) { - return; - } + int x1 = x + s * 32; + if (x1 <= -32 || x1 >= m_width) { + continue; + } else if (x1 < 0) { p >>= (unsigned int)-x1; x1 = 0; }