Fix TextInsertAlloc overflow by correcting loop bounds

This commit is contained in:
gideons 2026-07-16 10:01:24 +02:00
commit 6b2d8a37a9

View file

@ -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
}