From e37b7915908dba10e90c39a3a82cb0cd1dc05f5c Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Wed, 13 Mar 2019 10:52:39 +0000 Subject: Fix ImageSpace relocation direction check. The correct check whether `begin+diff` would overflow uint32_t is `begin >= -diff` in unsigned arithmetic. Note that with the current ranges of relocation diff and ART_BASE_ADDRESS, the result of the check is the same as before. Test: m test-art-host-gtest Bug: 77856493 Change-Id: Ic0ded458ad8fa327ea74e2e0ebdd4de18c4e5b04 --- runtime/gc/space/image_space.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/gc/space/image_space.cc b/runtime/gc/space/image_space.cc index 173e879192..3d676ae93c 100644 --- a/runtime/gc/space/image_space.cc +++ b/runtime/gc/space/image_space.cc @@ -1625,7 +1625,7 @@ class ImageSpace::BootImageLoader { // First patch the image header. The `diff` is OK for patching 32-bit fields but // the 64-bit method fields in the ImageHeader may need a negative `delta`. reinterpret_cast(space->Begin())->RelocateImage( - (reinterpret_cast32(space->Begin()) < diff) + (reinterpret_cast32(space->Begin()) >= -diff) // Would `begin+diff` overflow? ? -static_cast(-diff) : static_cast(diff)); // Patch fields and methods. -- cgit v1.2.3-59-g8ed1b