fix: guard Tiny FG misclass and add fg_tiny_gate box

This commit is contained in:
Moe Charm (CI)
2025-12-01 16:05:55 +09:00
parent f32d996edb
commit 2bd8da9267
4 changed files with 83 additions and 38 deletions

View File

@ -239,6 +239,8 @@ inline void* hak_alloc_at(size_t size, hak_callsite_t site) {
if (hdr->magic != HAKMEM_MAGIC) { fprintf(stderr, "[hakmem] ERROR: Invalid magic in allocated header!\n"); return ptr; }
hdr->alloc_site = site_id;
hdr->class_bytes = (size >= threshold) ? threshold : 0;
// Guard byte for FrontGate V2: force ptr[-1] away from 0xA?/0xB? to avoid Tiny misclass
((uint8_t*)hdr)[HEADER_SIZE - 1] = HAKMEM_FG_GUARD_BYTE;
#if HAKMEM_DEBUG_TIMING
HKM_TIME_END(HKM_CAT_HAK_ALLOC, t0);