about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorSzabolcs Nagy <nsz@port70.net>2016-01-31 17:31:03 +0100
committerRich Felker <dalias@aerifal.cx>2016-01-31 17:34:45 -0500
commitd1507646975cbf6c3e511ba07b193f27f032d108 (patch)
treeddac2ad8e132d01c5edfab866aba43f836595ffe /src
parent2810b30fc3c515e38d6acabe87de7b48bb8bfc7b (diff)
downloadmusl-d1507646975cbf6c3e511ba07b193f27f032d108.tar.gz
musl-d1507646975cbf6c3e511ba07b193f27f032d108.tar.xz
musl-d1507646975cbf6c3e511ba07b193f27f032d108.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/malloc/malloc_usable_size.c2
1 files changed, 1 insertions, 1 deletions
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;
 }