From 73744341846d4e76d6910dc5a15dff6d74586e39 Mon Sep 17 00:00:00 2001 From: quou Date: Thu, 19 Dec 2024 19:19:30 +1100 Subject: assert to prevent double free --- qstd/memory.c | 1 + 1 file changed, 1 insertion(+) (limited to 'qstd/memory.c') diff --git a/qstd/memory.c b/qstd/memory.c index 6ea43f7..81795d6 100644 --- a/qstd/memory.c +++ b/qstd/memory.c @@ -130,6 +130,7 @@ void* imp_heap_alloc(Heap* h, int s) { void imp_heap_free(Heap* h, void* p) { assert((char*)p > h->buf); assert((char*)p < h->buf + h->size); + assert(((int*)p)[-1] & ~((unsigned)-1 >> 1)); /* double free */ (void)h; ((int*)p)[-1] &= (unsigned)-1 >> 1; } -- cgit v1.2.3-54-g00ecf