From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kostaras Nikolaos Date: Thu, 21 Oct 2010 12:24:01 +0300 Subject: [U-Boot] [PATCH] Prevent malloc with size 0 Message-ID: <4CC006B1.8000905@intracomdefense.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de In case malloc is invoked with requested size 0, this patch will prevent the execution of the allocation algorithm (because it corrupts the data structures) and will return 0 to the caller. Signed-off-by: Nikolaos Kostaras --- common/dlmalloc.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/common/dlmalloc.c b/common/dlmalloc.c index fce7a76..d9e3ea9 100644 --- a/common/dlmalloc.c +++ b/common/dlmalloc.c @@ -2182,7 +2182,7 @@ Void_t* mALLOc(bytes) size_t bytes; return 0; } - if ((long)bytes < 0) return 0; + if ((long)bytes <= 0) return 0; nb = request2size(bytes); /* padded request size; */ -- 1.6.4.4