Skip to content

Commit 3f517a1

Browse files
lum1n0usclaude
andcommitted
feat(mem-alloc): add realloc rejection for aligned allocs
gc_realloc_vo now detects and rejects aligned allocations per POSIX behavior. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 870bf00 commit 3f517a1

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

core/shared/mem-alloc/ems/ems_alloc.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,16 @@ gc_realloc_vo_internal(void *vheap, void *ptr, gc_size_t size, const char *file,
778778
}
779779
#endif
780780

781+
/* Check if this is an aligned allocation - not supported */
782+
if (obj_old) {
783+
uint32_t *magic_ptr = (uint32_t *)((char *)obj_old - 4);
784+
if ((*magic_ptr & ALIGNED_ALLOC_MAGIC_MASK) == ALIGNED_ALLOC_MAGIC_VALUE) {
785+
LOG_ERROR("[GC_ERROR]gc_realloc_vo does not support aligned "
786+
"allocations\n");
787+
return NULL;
788+
}
789+
}
790+
781791
if (obj_old) {
782792
hmu_old = obj_to_hmu(obj_old);
783793
tot_size_old = hmu_get_size(hmu_old);

0 commit comments

Comments
 (0)