commit 5302d5272a7dbe0823fc64220a549420e8f74937
parent 0b0e925f5e7422222cbaf8dc4de0121c5d9da5d3
Author: sin <sin@2f30.org>
Date: Wed, 24 Jul 2013 18:40:49 +0300
malloc_usable_size() should only work on allocated chunks
Diffstat:
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/alloc.c b/alloc.c
@@ -109,7 +109,7 @@ malloc_usable_size(void *p)
if (!p)
return 0;
for (i = 0; i < NALLOC; i++)
- if (chunks[i].base == p)
+ if (chunks[i].base == p && chunks[i].state == ALLOCATED)
return chunks[i].size;
return 0;
}