You need to sign in or sign up before continuing.
提交 d1507646 编写于 作者: S Szabolcs Nagy 提交者: Rich Felker

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.
上级 2810b30f
...@@ -13,5 +13,5 @@ struct chunk { ...@@ -13,5 +13,5 @@ struct chunk {
size_t malloc_usable_size(void *p) 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;
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册