[ast-value-factory] Fix length mismatch in string comparison

When comparing two-byte strings, the correct number of characters to
compare is length(), not byte_length().

The bug was introduced in
https://chromium-review.googlesource.com/c/v8/v8/+/2533038

There's no regression test, since going beyond the AstRawString
boundary generally doesn't crash.

Bug: chromium:1151602
Change-Id: I32c297c2751835dd7574ff928d2d5b8346b4381a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2551110
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Commit-Queue: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71330}
This commit is contained in:
Marja Hölttä 2020-11-23 09:35:31 +01:00 committed by Commit Bot
parent e49ea59739
commit 141ede2ec1

View File

@ -153,7 +153,7 @@ int AstRawString::Compare(const AstRawString* lhs, const AstRawString* rhs) {
const unsigned char* lhs_data = lhs->raw_data();
const unsigned char* rhs_data = rhs->raw_data();
size_t length = std::min(lhs->byte_length(), rhs->byte_length());
size_t length = std::min(lhs->length(), rhs->length());
// Code point order by contents.
if (lhs->is_one_byte()) {