From e652753f9570afd688d8b62c8d8f9b321b901d7b Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Mon, 30 Apr 2012 13:31:29 +0200 Subject: tlsf_malloc: return valid pointer for malloc(0) Signed-off-by: Sascha Hauer --- common/tlsf_malloc.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'common/tlsf_malloc.c') diff --git a/common/tlsf_malloc.c b/common/tlsf_malloc.c index 2fe443bf2b..8143d660f5 100644 --- a/common/tlsf_malloc.c +++ b/common/tlsf_malloc.c @@ -33,6 +33,13 @@ extern tlsf_pool tlsf_mem_pool; void *malloc(size_t bytes) { + /* + * tlsf_malloc returns NULL for zero bytes, we instead want + * to have a valid pointer. + */ + if (!bytes) + bytes = 1; + return tlsf_malloc(tlsf_mem_pool, bytes); } EXPORT_SYMBOL(malloc); -- cgit v1.2.3