From eb998bda6206682be424fd8c2fca9810f53e3fdf Mon Sep 17 00:00:00 2001 From: jgrubb Date: Sat, 14 Jul 2007 00:07:43 +0000 Subject: [PATCH] Bug fix #20478: memp_malloc returns NULL+MEMP_SIZE rather than NULL on a failed allocation --- src/core/memp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/core/memp.c b/src/core/memp.c index 98192bb9..8d6bbb3b 100644 --- a/src/core/memp.c +++ b/src/core/memp.c @@ -278,6 +278,8 @@ memp_overflow_init(void) /** * Initialize this module. + * + * Carves out memp_memory into linked lists for each pool-type. */ void memp_init(void) @@ -359,7 +361,8 @@ memp_malloc(memp_t type) SYS_ARCH_UNPROTECT(old_level); - return (void*)((u8_t*)memp + MEMP_SIZE); + /* (bug fix #20478): dont return NULL+MEMP_SIZE! */ + return (memp ? (void*)((u8_t*)memp + MEMP_SIZE) : NULL ); } /**