Skip to content

Commit 30a0fd5

Browse files
kddnewtonmeta-codesync[bot]
authored andcommitted
Assert before dividing to avoid truncation
Summary: Assert that we are divisible by 4. This should always be the case, but it was suggested in code review for safety. Reviewed By: alexmalyshev Differential Revision: D91475694 fbshipit-source-id: de3f7f62e825977a2bdbb694402162ca4f003c41
1 parent 58bc0c4 commit 30a0fd5

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

cinderx/Jit/code_patcher.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ void JumpPatcher::linkJump(uintptr_t patchpoint, uintptr_t jump_target) {
137137
buf[0] = 0xe9;
138138
std::memcpy(buf.data() + 1, &disp, sizeof(uint32_t));
139139
#elif defined(CINDER_AARCH64)
140+
JIT_CHECK(
141+
disp % 4 == 0, "Jump displacement must be a multiple of 4, got {}", disp);
142+
140143
disp /= 4;
141144
JIT_CHECK(fitsSignedInt<26>(disp), "Not enough bits to encode relative jump");
142145

0 commit comments

Comments
 (0)