Skip to content

Conversation

@tobil4sk
Copy link
Member

@tobil4sk tobil4sk commented Sep 2, 2025

If c is negative (this can happen if char is signed), then accessing sConstStrings[c] is an out of bounds memory access. This results in a string being created from garbage memory, which can lead to seg faults later on.

Taking the other branch is safer in this case. While the behaviour with negative values is unspecified, it is unsafe to give out of bounds access to memory like this.

This is partly the cause of the crash in #865.

If c is negative (this can happen if char is signed), then accessing
sConstStrings[c] is an out of bounds memory access. This results in a
string being created from garbage memory, which can lead to seg faults
later on.

Taking the other branch is safer in this case.
@Simn Simn merged commit 1618253 into HaxeFoundation:master Sep 2, 2025
120 checks passed
@tobil4sk tobil4sk deleted the fix/String-fromCharCode-invalid-array-access branch September 2, 2025 22:57
mikolka9144 added a commit to Psych-Slice/hxcpp that referenced this pull request Oct 7, 2025
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