From 93e64f2210be64250641b94ab259d85b53ba8639 Mon Sep 17 00:00:00 2001 From: GideonSerf Date: Thu, 16 Jul 2026 12:08:41 +0200 Subject: [PATCH] Fix TextInsertAlloc overflow by correcting loop bounds (#5982) Co-authored-by: gideons --- src/rtext.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rtext.c b/src/rtext.c index 248857975..0431a6f57 100644 --- a/src/rtext.c +++ b/src/rtext.c @@ -2014,7 +2014,7 @@ char *TextInsertAlloc(const char *text, const char *insert, int position) for (int i = 0; i < position; i++) result[i] = text[i]; for (int i = position; i < (insertLen + position); i++) result[i] = insert[i - position]; - for (int i = (insertLen + position); i < (textLen + insertLen + position); i++) result[i] = text[i - insertLen]; + for (int i = (insertLen + position); i < (textLen + insertLen); i++) result[i] = text[i - insertLen]; result[textLen + insertLen] = '\0'; // Add EOL }