Skip to content

Commit aaab1b9

Browse files
committed
Don't crash if we break a line between '\r' and '\n'
We probably shouldn't be doing that anyway, but at least we won't crash now if we do. Fixes #517
1 parent 3413365 commit aaab1b9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/SDL_ttf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4196,7 +4196,7 @@ static bool GetWrappedLines(TTF_Font *font, const char *text, size_t length, TTF
41964196
// The line doesn't include any delimiter that caused it to be wrapped.
41974197
if (CharacterIsNewLine(line->text[line->length - 1])) {
41984198
--line->length;
4199-
if (line->text[line->length - 1] == '\r') {
4199+
if (line->length > 0 && line->text[line->length - 1] == '\r') {
42004200
--line->length;
42014201
}
42024202
} else if (i < (numLines - 1) &&

0 commit comments

Comments
 (0)