From c9d185d2b4ac045840586d3a890eab61c922379f Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Thu, 16 Apr 2015 11:54:24 -0700 Subject: Fix undefined behavior in hash calculation. dex_register might be >= the width of the map hash. Shifting by that value would be undefined behavior. Constrain the value to within the valid range. Change-Id: I9037c5c7ec554850ba3385585aca96fde1d50387 --- compiler/optimizing/stack_map_stream.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'compiler/optimizing/stack_map_stream.h') diff --git a/compiler/optimizing/stack_map_stream.h b/compiler/optimizing/stack_map_stream.h index a73c8d77f3..9a9e068a9b 100644 --- a/compiler/optimizing/stack_map_stream.h +++ b/compiler/optimizing/stack_map_stream.h @@ -386,7 +386,8 @@ class StackMapStream : public ValueObject { } entry.live_dex_registers_mask->SetBit(dex_register); - entry.dex_register_map_hash += (1 << dex_register); + entry.dex_register_map_hash += + (1 << (dex_register % (sizeof(entry.dex_register_map_hash) * kBitsPerByte))); entry.dex_register_map_hash += static_cast(value); entry.dex_register_map_hash += static_cast(kind); stack_maps_.Put(stack_maps_.Size() - 1, entry); -- cgit v1.2.3-59-g8ed1b