Commit 141ede2e authored by Marja Hölttä's avatar Marja Hölttä Committed by Commit Bot

[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/+/2551110Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71330}
parent e49ea597
......@@ -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()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment