]> Git Repo - J-u-boot.git/commitdiff
malloc_simple: calloc: don't call memset if malloc failed
authorSimon Goldschmidt <[email protected]>
Thu, 16 Aug 2018 07:50:32 +0000 (09:50 +0200)
committerTom Rini <[email protected]>
Fri, 24 Aug 2018 17:20:19 +0000 (13:20 -0400)
malloc_simple() can return 0 if out of memory. Don't call memset
from calloc() in this case but rely on the caller checking
the return value.

Signed-off-by: Simon Goldschmidt <[email protected]>
Reviewed-by: Marek Vasut <[email protected]>
common/malloc_simple.c

index c14f8b59c178ee251cc79299f9fcccfbcb1e340a..871b5444bd7d89e48eef21527d172927788d2e40 100644 (file)
@@ -57,7 +57,8 @@ void *calloc(size_t nmemb, size_t elem_size)
        void *ptr;
 
        ptr = malloc(size);
-       memset(ptr, '\0', size);
+       if (ptr)
+               memset(ptr, '\0', size);
 
        return ptr;
 }
This page took 0.034792 seconds and 4 git commands to generate.