[PLAT-8434] Fix improper use of TCHAR_TO_UTF8 #157
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Goal
Fix a customer-reported use-after-free crash in
FAndroidPlatformJNI::ParseFString()
when passed a large string, due to improper use ofTCHAR_TO_UTF8()
.StringConv.h states that results should not be captured in a variable:
UE's string conversion use different allocation strategies depending on the size of the data, switching at 128 bytes.
Changeset
Uses
TCHAR_TO_UTF8()
in the recommended way - as a parameter toNewStringUTF()
There is no need for a null check since, given a non-null pointer (which
FString::operator*()
returns),TCHAR_TO_ANSI()
will also return a non-null pointer.Testing
Was unable to reproduce a crash, even when testing with large strings of over 128 bytes.