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.
This commit is contained in:
parent
d86b3fe134
commit
2b860d9067
@ -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());
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user