summaryrefslogtreecommitdiff
path: root/compiler/optimizing/stack_map_stream.h
diff options
context:
space:
mode:
author Dan Albert <danalbert@google.com> 2015-04-16 11:54:24 -0700
committer Dan Albert <danalbert@google.com> 2015-04-17 10:23:55 -0700
commitc9d185d2b4ac045840586d3a890eab61c922379f (patch)
treefcd621ffa8bd526ab6eddc372d951102aa4a1ec0 /compiler/optimizing/stack_map_stream.h
parente50dffa29fb6c67eba44e267aa890d35712de9dd (diff)
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
Diffstat (limited to 'compiler/optimizing/stack_map_stream.h')
-rw-r--r--compiler/optimizing/stack_map_stream.h3
1 files changed, 2 insertions, 1 deletions
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<uint32_t>(value);
entry.dex_register_map_hash += static_cast<uint32_t>(kind);
stack_maps_.Put(stack_maps_.Size() - 1, entry);