Skip to content

Commit

Permalink
GRIM: Prevent crash on empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
phcoder committed Mar 6, 2023
1 parent 349c553 commit 7d96a1c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions engines/grim/textobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ void TextObject::setupText() {
delete[] _lines;
if (msg.size() == 0) {
_lines = nullptr;
_numberLines = 0;
return;
}

Expand Down Expand Up @@ -288,6 +289,8 @@ void TextObject::setupText() {

int TextObject::getLineX(int line) const {
int x = _x;
if (line >= _numberLines)
return 0;
if (_justify == CENTER)
x = _x - (_font->getKernedStringLength(_lines[line]) / 2);
else if (_justify == RJUSTIFY)
Expand Down

0 comments on commit 7d96a1c

Please sign in to comment.