summaryrefslogtreecommitdiff
path: root/qstd
diff options
context:
space:
mode:
authorquou <quou@disroot.org>2024-12-19 19:19:30 +1100
committerquou <quou@disroot.org>2024-12-19 19:19:30 +1100
commit73744341846d4e76d6910dc5a15dff6d74586e39 (patch)
tree97c21bd4740b3086d68a2f1dc3c1ba155c0caa5f /qstd
parent8199bfa31fa59fb060d2939f8612dea575b249d3 (diff)
assert to prevent double free
Diffstat (limited to 'qstd')
-rw-r--r--qstd/memory.c1
1 files changed, 1 insertions, 0 deletions
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;
}