summaryrefslogtreecommitdiff
path: root/include/mimalloc-internal.h
diff options
context:
space:
mode:
authordaan <daanl@outlook.com>2020-07-25 19:33:02 -0700
committerdaan <daanl@outlook.com>2020-07-25 19:33:02 -0700
commitafe29cb8f5e6550438565dc02574fd307d0e983c (patch)
treefb34b6143919620a5f715959e5c9999009dbe641 /include/mimalloc-internal.h
parenta9a21f39d8de1990255d061bfdd5588cc86d24fc (diff)
fix ub on shift, issue #279
Diffstat (limited to 'include/mimalloc-internal.h')
-rw-r--r--include/mimalloc-internal.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/include/mimalloc-internal.h b/include/mimalloc-internal.h
index ba322fe..2dc7e36 100644
--- a/include/mimalloc-internal.h
+++ b/include/mimalloc-internal.h
@@ -574,11 +574,11 @@ static inline bool mi_is_in_same_page(const void* p, const void* q) {
static inline uintptr_t mi_rotl(uintptr_t x, uintptr_t shift) {
shift %= MI_INTPTR_BITS;
- return ((x << shift) | (x >> (MI_INTPTR_BITS - shift)));
+ return (shift==0 ? x : ((x << shift) | (x >> (MI_INTPTR_BITS - shift))));
}
static inline uintptr_t mi_rotr(uintptr_t x, uintptr_t shift) {
shift %= MI_INTPTR_BITS;
- return ((x >> shift) | (x << (MI_INTPTR_BITS - shift)));
+ return (shift==0 ? x : ((x >> shift) | (x << (MI_INTPTR_BITS - shift))));
}
static inline void* mi_ptr_decode(const void* null, const mi_encoded_t x, const uintptr_t* keys) {