diff --git a/runtime/ecma_string.cpp b/runtime/ecma_string.cpp index 8b6d085c3b5d36c84a27ff253cd544ca3146a78c..b784b485f2f205083b031101eca984349e0c82dd 100644 --- a/runtime/ecma_string.cpp +++ b/runtime/ecma_string.cpp @@ -411,11 +411,12 @@ uint32_t EcmaString::ComputeHashcodeUtf8(const uint8_t *utf8Data, size_t utf8Len if (canBeCompress) { hash = ComputeHashForUtf8(utf8Data); } else { - auto utf16Len = base::utf_helper::Utf8ToUtf16Size(utf8Data, utf8Len); + // utf8len >= utf16len for equal strings + auto utf16Len = utf8Len; PandaVector tmpBuffer(utf16Len); [[maybe_unused]] auto len = base::utf_helper::ConvertRegionUtf8ToUtf16(utf8Data, tmpBuffer.data(), utf8Len, utf16Len, 0); - ASSERT(len == utf16Len); + ASSERT(len == base::utf_helper::Utf8ToUtf16Size(utf8Data, utf8Len)); hash = ComputeHashForData(tmpBuffer.data(), utf16Len); } return hash;