mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-28 03:25:23 +00:00
BumpPtrAllocator: use uintptr_t when aligning addresses to avoid undefined behaviour
In theory, alignPtr() could push a pointer beyond the end of the current slab, making comparisons with that pointer undefined behaviour. Use an integer type to avoid this. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216973 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -130,7 +130,7 @@ public:
|
||||
void *MemBase = malloc(Size + Alignment - 1 + sizeof(void*));
|
||||
|
||||
// Find the slab start.
|
||||
void *Slab = alignPtr((char *)MemBase + sizeof(void *), Alignment);
|
||||
void *Slab = (void *)alignAddr((char*)MemBase + sizeof(void *), Alignment);
|
||||
|
||||
// Hold a pointer to the base so we can free the whole malloced block.
|
||||
((void**)Slab)[-1] = MemBase;
|
||||
|
Reference in New Issue
Block a user