From cebf19a071df7a9f4e4b214f4c846a2ecc6ddb97 Mon Sep 17 00:00:00 2001 From: Kurt Hindenburg Date: Thu, 27 Nov 2025 17:41:36 -0500 Subject: [PATCH] Fix over/underflowed return value (coverity) stringWidth() could return a negative value as width() returns negative on some characters. This fixes by returning 0 at a mininum. --- src/characters/Character.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/characters/Character.h b/src/characters/Character.h index b907f1f04..3cd9cc698 100644 --- a/src/characters/Character.h +++ b/src/characters/Character.h @@ -349,7 +349,9 @@ public: w += Hangul::width(c, width(c, ignoreWcWidth), hangulSyllablePos); } } - return w; + // Do not return a negative width. width() can be negative and could + // make the return value here be negative. + return (w < 0) ? 0 : w; } inline static int stringWidth(const QString &str, bool ignoreWcWidth = false)