projects
/
project
/
bcm63xx
/
u-boot.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
a5e34fc
)
malloc_simple: calloc: don't call memset if malloc failed
author
Simon Goldschmidt
<simon.k.r.goldschmidt@gmail.com>
Thu, 16 Aug 2018 07:50:32 +0000
(09:50 +0200)
committer
Tom Rini
<trini@konsulko.com>
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 <simon.k.r.goldschmidt@gmail.com>
Reviewed-by: Marek Vasut <marex@denx.de>
common/malloc_simple.c
patch
|
blob
|
history
diff --git
a/common/malloc_simple.c
b/common/malloc_simple.c
index c14f8b59c178ee251cc79299f9fcccfbcb1e340a..871b5444bd7d89e48eef21527d172927788d2e40 100644
(file)
--- a/
common/malloc_simple.c
+++ b/
common/malloc_simple.c
@@
-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;
}