Fix TextInsertAlloc overflow by correcting loop bounds (#5982)
Co-authored-by: gideons <gse@newspacesystems.com>
This commit is contained in:
parent
a9a0c046f1
commit
93e64f2210
1 changed files with 1 additions and 1 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue