Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop possible underrun when processing a string #89671

Merged
1 commit merged into from
Mar 24, 2024

Conversation

alesliehughes
Copy link
Contributor

Calling String::utf8("Unicode String", -1) assumes that the string will be NULL terminated. However, the length parameter is always used to find the end of the string. So there is the chance the character before th start of the string is read.

Making the pointer NULL in the case where it's out of range, still allows the following to work as expected
while (ptrtmp != ptrtmp_limit && *ptrtmp)

@alesliehughes alesliehughes requested a review from a team as a code owner March 19, 2024 08:48
core/string/ustring.cpp Outdated Show resolved Hide resolved
Calling String::utf8("Unicode String", -1) assumes that the string will be NULL terminated.
However, the length parameter is always used to find the end of the string.  So there is the
chance the character before th start of the string is read.

Making the pointer NULL in the case where it's out of range, still allows the following
to work as expected
while (ptrtmp != ptrtmp_limit && *ptrtmp)
....
@akien-mga akien-mga closed this pull request by merging all changes into godotengine:master in 06abc86 Mar 24, 2024
akien-mga added a commit that referenced this pull request Mar 24, 2024
Stop possible underrun when processing a string
@akien-mga
Copy link
Member

Thanks!

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

Successfully merging this pull request may close these issues.

4 participants