Prevent overflow from bit shifting (#12566) chunseok/svace accepted/tizen/unified/20240202.165957 accepted/tizen/unified/toolchain/20240311.065344 accepted/tizen/unified/x/20240205.063928
authorseongwoo chae <mhs4670go@naver.com>
Tue, 30 Jan 2024 21:21:18 +0000 (06:21 +0900)
committerChunseok Lee <chunseok.lee@samsung.com>
Thu, 1 Feb 2024 07:57:07 +0000 (16:57 +0900)
This commit prevents an overflow from bit shifting.

ONE-DCO-1.0-Signed-off-by: seongwoo <mhs4670go@naver.com>

compiler/luci-interpreter/include/luci_interpreter/BuddyMemoryManager.h

index 205baa6..fec0899 100644 (file)
@@ -114,7 +114,7 @@ private:
     const int32_t l = lowerLog2(block->size + sizeof(Block));
 
     const int64_t address = ((uint8_t *)block - (uint8_t *)_start_block);
-    buddy = (Block *)((address ^ (1 << l)) + (uint8_t *)_start_block);
+    buddy = (Block *)((address ^ (1LL << l)) + (uint8_t *)_start_block);
 
     if (!buddy->is_free || buddy->size != block->size)
       return nullptr;