From 2b860d90674d4e82e7195261d53c60c495c0bbcb Mon Sep 17 00:00:00 2001 From: IFAKA Date: Fri, 19 Dec 2025 01:07:38 +0100 Subject: [PATCH] Fix title truncation underflow when title is shorter than 8 chars The status bar title truncation loop could crash if the title length was less than 8 characters, as title.length() - 8 would underflow (size_t is unsigned). Added a length check to prevent this. --- src/activities/reader/EpubReaderActivity.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/activities/reader/EpubReaderActivity.cpp b/src/activities/reader/EpubReaderActivity.cpp index f4e4536..3bae96d 100644 --- a/src/activities/reader/EpubReaderActivity.cpp +++ b/src/activities/reader/EpubReaderActivity.cpp @@ -382,7 +382,7 @@ void EpubReaderActivity::renderStatusBar() const { const auto tocItem = epub->getTocItem(tocIndex); title = tocItem.title; titleWidth = renderer.getTextWidth(SMALL_FONT_ID, title.c_str()); - while (titleWidth > availableTextWidth) { + while (titleWidth > availableTextWidth && title.length() > 11) { title = title.substr(0, title.length() - 8) + "..."; titleWidth = renderer.getTextWidth(SMALL_FONT_ID, title.c_str()); }