|
Message-ID: <20160131163102.GX9621@port70.net> Date: Sun, 31 Jan 2016 17:31:03 +0100 From: Szabolcs Nagy <nsz@...t70.net> To: musl@...ts.openwall.com Subject: [PATCH] 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. --- src/malloc/malloc_usable_size.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/malloc/malloc_usable_size.c b/src/malloc/malloc_usable_size.c index 8cccd9d..6743ea7 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; } -- 2.7.0
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.