Skip to content

Commit

Permalink
Don't crash if we break a line between '\r' and '\n'
Browse files Browse the repository at this point in the history
We probably shouldn't be doing that anyway, but at least we won't crash now if we do.

Fixes #517
  • Loading branch information
slouken committed Feb 27, 2025
1 parent 3413365 commit aaab1b9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/SDL_ttf.c
Original file line number Diff line number Diff line change
Expand Up @@ -4196,7 +4196,7 @@ static bool GetWrappedLines(TTF_Font *font, const char *text, size_t length, TTF
// The line doesn't include any delimiter that caused it to be wrapped.
if (CharacterIsNewLine(line->text[line->length - 1])) {
--line->length;
if (line->text[line->length - 1] == '\r') {
if (line->length > 0 && line->text[line->length - 1] == '\r') {
--line->length;
}
} else if (i < (numLines - 1) &&
Expand Down

0 comments on commit aaab1b9

Please sign in to comment.