Skip to content

[rtext] Fix TextInsertAlloc buffer overflow#5982

Merged
raysan5 merged 1 commit into
raysan5:masterfrom
GideonSerf:fix-textinsertalloc-overflow
Jul 16, 2026
Merged

[rtext] Fix TextInsertAlloc buffer overflow#5982
raysan5 merged 1 commit into
raysan5:masterfrom
GideonSerf:fix-textinsertalloc-overflow

Conversation

@GideonSerf

@GideonSerf GideonSerf commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Problem

TextInsertAlloc() allocates textLen + insertLen + 1 bytes, but its suffix-copy loop iterates until textLen + insertLen + position.

For any insertion position greater than zero, this reads beyond the source string and writes beyond the allocated result buffer.

Fix

Remove the duplicated position term from the suffix-copy loop bound.

Validation

  • Reproduced the original overflow with MSVC AddressSanitizer

@raysan5 raysan5 merged commit 93e64f2 into raysan5:master Jul 16, 2026
16 checks passed
@raysan5

raysan5 commented Jul 16, 2026

Copy link
Copy Markdown
Owner

@GideonSerf thanks for the review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants