mirror of https://github.com/axmolengine/axmol.git
* fixed #16169: new android project crash in android 5.0.2 device (Nexus 7) when use 3.12 * fixed #16169: Adds comments for why we should not use `assignment operator` of `std::u16string`.
This commit is contained in:
parent
493b74ab7e
commit
66fac82f00
|
@ -265,7 +265,20 @@ void FontAtlas::findNewCharacters(const std::u16string& u16Text, std::unordered_
|
|||
//find new characters
|
||||
if (_letterDefinitions.empty())
|
||||
{
|
||||
newChars = u16Text;
|
||||
// fixed #16169: new android project crash in android 5.0.2 device (Nexus 7) when use 3.12.
|
||||
// While using clang compiler with gnustl_static on android, the copy assignment operator of `std::u16string`
|
||||
// will affect the memory validity, it means after `newChars` is destroyed, the memory of `u16Text` holds
|
||||
// will be a dead region. `u16text` represents the variable in `Label::_utf16Text`, when somewhere
|
||||
// allocates memory by `malloc, realloc, new, new[]`, the generated memory address may be the same
|
||||
// as `Label::_utf16Text` holds. If doing a `memset` or other memory operations, the orignal `Label::_utf16Text`
|
||||
// will be in an unknown state. Meanwhile, a bunch lots of logic which depends on `Label::_utf16Text`
|
||||
// will be broken.
|
||||
|
||||
// newChars = u16Text;
|
||||
|
||||
// Using `append` method is a workaround for this issue. So please be carefuly while using the assignment operator
|
||||
// of `std::u16string`.
|
||||
newChars.append(u16Text);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue