From de87dd2c1c36e284b39d09836f0650ee29308efe Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Tue, 28 Jan 2025 10:33:54 -0800
Subject: [PATCH] Fixed infinite loop with a small wrap width and whitespace at
the end of the string
Fixes https://github.com/libsdl-org/SDL_ttf/issues/482
---
src/SDL_ttf.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/SDL_ttf.c b/src/SDL_ttf.c
index b48e25d9..35e39c3c 100644
--- a/src/SDL_ttf.c
+++ b/src/SDL_ttf.c
@@ -3941,6 +3941,9 @@ static bool GetWrappedLines(TTF_Font *font, const char *text, size_t length, TTF
if (numLines > 0) {
strLines[numLines - 1].length = spot - strLines[numLines - 1].text;
}
+ if (*spot == '\0') {
+ break;
+ }
strLines[numLines].text = spot;
strLines[numLines].length = left;
++numLines;