Module: sip-router
Branch: 3.3
Commit: efd3fad94f179b27ac364c16df6cd69d27d814c3
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=efd3fad…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Mon Dec 2 20:42:12 2013 +0100
mem: malloc(0) should return a valid pointer for free according to specs
(cherry picked from commit f61ff34aac7c7bae3a96fb698a899c8a0e692a9f)
(cherry picked from commit e605174dab9b86ce06689d184b4b9d81288f1193)
---
mem/f_malloc.c | 2 ++
mem/q_malloc.c | 2 ++
2 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/mem/f_malloc.c b/mem/f_malloc.c
index 008874b..7a0e115 100644
--- a/mem/f_malloc.c
+++ b/mem/f_malloc.c
@@ -361,6 +361,8 @@ void* fm_malloc(struct fm_block* qm, unsigned long size)
MDBG("fm_malloc(%p, %lu) called from %s: %s(%d)\n", qm, size, file, func,
line);
#endif
+ /*malloc(0) should return a valid pointer according to specs*/
+ if(unlikely(size==0)) size=4;
/*size must be a multiple of 8*/
size=ROUNDUP(size);
/* if (size>(qm->size-qm->real_used)) return 0; */
diff --git a/mem/q_malloc.c b/mem/q_malloc.c
index 497c3f9..f966c3f 100644
--- a/mem/q_malloc.c
+++ b/mem/q_malloc.c
@@ -368,6 +368,8 @@ void* qm_malloc(struct qm_block* qm, unsigned long size)
MDBG("qm_malloc(%p, %lu) called from %s: %s(%d)\n", qm, size, file, func,
line);
#endif
+ /*malloc(0) should return a valid pointer according to specs*/
+ if(unlikely(size==0)) size=4;
/*size must be a multiple of 8*/
size=ROUNDUP(size);
if (size>(qm->size-qm->real_used)) return 0;