Skip to content

Commit 7d0c58f

Browse files
committed
calculate the address of the size in a different way
1 parent f839f1d commit 7d0c58f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

stringdtype/stringdtype/src/static_string.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,8 @@ heap_or_arena_allocate(npy_string_allocator *allocator,
314314
}
315315
else {
316316
// not necessarily memory-aligned, so need to use memcpy
317-
memcpy(&alloc_size, ((size_t *)buf - 1), sizeof(size_t));
317+
char *size_loc = (char *)((uintptr_t)buf - sizeof(size_t));
318+
memcpy(&alloc_size, size_loc, sizeof(size_t));
318319
}
319320
if (size <= alloc_size) {
320321
// we have room!

0 commit comments

Comments
 (0)