[PATCH 4/4] tlsf_malloc: return valid pointer for malloc(0)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
---
 common/tlsf_malloc.c |    7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/common/tlsf_malloc.c b/common/tlsf_malloc.c
index 2fe443b..8143d66 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);
-- 
1.7.10


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox


[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux