From 2d82638cba363034f3e2faa9fdea28c2ab13c691 Mon Sep 17 00:00:00 2001
From: Sylvain <[EMAIL REDACTED]>
Date: Mon, 3 Jan 2022 20:06:39 +0100
Subject: [PATCH] Changed realloc increment for maxNumLines
---
SDL_ttf.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/SDL_ttf.c b/SDL_ttf.c
index 14dc40a..7481f72 100644
--- a/SDL_ttf.c
+++ b/SDL_ttf.c
@@ -3364,7 +3364,11 @@ static SDL_Surface* TTF_Render_Wrapped_Internal(TTF_Font *font, const char *text
if (numLines >= maxNumLines) {
char **saved = strLines;
- maxNumLines += (width / (wrapLength + 1)) + 1;
+ if (wrapLength == 0) {
+ maxNumLines += 32;
+ } else {
+ maxNumLines += (width / wrapLength) + 1;
+ }
strLines = (char **)SDL_realloc(strLines, maxNumLines * sizeof (*strLines));
if (strLines == NULL) {
strLines = saved;