!9586 Bugfix: heap pointer may be invalid after gc

Merge pull request !9586 from lukai/stringtablebugfix
This commit is contained in:
openharmony_ci 2024-10-06 14:39:53 +00:00 committed by Gitee
commit 62caefba91
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -257,6 +257,8 @@ EcmaString *EcmaStringTable::GetOrInternCompressedSubString(EcmaVM *vm, const JS
vm->IncreaseStringTableLockCount();
}
#endif
// utf8data may be moved after shared full gc, so reload utf8Data here.
utf8Data = EcmaStringAccessor(string).GetDataUtf8() + offset;
std::pair<EcmaString *, uint32_t> result = GetStringThreadUnsafe(utf8Data, utf8Len, true, hashcode);
if (result.first != nullptr) {
return result.first;