Commit 145a8f44 authored by Igor Sheludko's avatar Igor Sheludko Committed by Commit Bot

[ubsan] Fix UB in StringHasher::GetTrivialHash()

... which broke with 32-bit Smis.

Tbr: verwaest@chromium.org
No-Tree-Checks: true
Bug: v8:9767
Change-Id: I459a5d807d87012ab72138f46b49362f16b6baa1
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1862562Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarSathya Gunasekaran  <gsathya@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64289}
parent 1ec2ca26
......@@ -34,8 +34,8 @@ uint32_t StringHasher::GetHashCore(uint32_t running_hash) {
uint32_t StringHasher::GetTrivialHash(int length) {
DCHECK_GT(length, String::kMaxHashCalcLength);
// String hash of a large string is simply the length.
return (length << String::kHashShift) | String::kIsNotArrayIndexMask |
String::kIsNotIntegerIndexMask;
return (static_cast<uint32_t>(length) << String::kHashShift) |
String::kIsNotArrayIndexMask | String::kIsNotIntegerIndexMask;
}
template <typename schar>
......
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