From: Szabolcs Nagy Date: Sun, 31 Jan 2016 16:31:03 +0000 (+0100) Subject: fix malloc_usable_size for NULL input X-Git-Tag: v1.1.13~11 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=d1507646975cbf6c3e511ba07b193f27f032d108;p=oweals%2Fmusl.git fix malloc_usable_size for NULL input the linux man page specifies malloc_usable_size(0) to return 0 and this is the semantics other implementations follow (jemalloc). reported by Alexander Monakov. --- diff --git a/src/malloc/malloc_usable_size.c b/src/malloc/malloc_usable_size.c index 8cccd9d8..6743ea77 100644 --- a/src/malloc/malloc_usable_size.c +++ b/src/malloc/malloc_usable_size.c @@ -13,5 +13,5 @@ struct chunk { size_t malloc_usable_size(void *p) { - return CHUNK_SIZE(MEM_TO_CHUNK(p)) - OVERHEAD; + return p ? CHUNK_SIZE(MEM_TO_CHUNK(p)) - OVERHEAD : 0; }