projects
/
oweals
/
musl.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
2810b30
)
fix malloc_usable_size for NULL input
author
Szabolcs Nagy
<nsz@port70.net>
Sun, 31 Jan 2016 16:31:03 +0000
(17:31 +0100)
committer
Rich Felker
<dalias@aerifal.cx>
Sun, 31 Jan 2016 22:34:45 +0000
(17:34 -0500)
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
patch
|
blob
|
history
diff --git
a/src/malloc/malloc_usable_size.c
b/src/malloc/malloc_usable_size.c
index 8cccd9d8d68b2e4fc6a230a7e9f0537a60c2353a..6743ea7752a0c44305b009c80ad7b23d153a5ac0 100644
(file)
--- 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
;
}