summaryrefslogtreecommitdiff
path: root/payloads/libpayload/libc/malloc.c
diff options
context:
space:
mode:
authorJonathan Neuschäfer <j.neuschaefer@gmx.net>2016-04-05 21:36:34 +0200
committerNico Huber <nico.h@gmx.de>2016-04-06 13:33:07 +0200
commita4fbc385e0910510b0e46007a51c8d48609e88a8 (patch)
tree26d4b0c22df6be9ecf8af4da7e21f7c7b78f77db /payloads/libpayload/libc/malloc.c
parent2fff2a6e31312be2894c8e7c1a4f53cb14e94a74 (diff)
libpayload/libc: Fix memset/sizeof usage
Since r is a pointer, memset(r, 0, sizeof(r)) would only zero the first 4 (or 8) bytes of the newly allocated struct align_region_t. An alternative to this patch would be to use calloc, or introduce a new zalloc (zeroed allocation; a single-element calloc) and use that. Change-Id: Ic3e3487ce749eeebf6c4836e62b8a305ad766e7e Found-by: Coverity (ID 1291160) Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net> Reviewed-on: https://review.coreboot.org/14244 Reviewed-by: Aaron Durbin <adurbin@chromium.org> Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Diffstat (limited to 'payloads/libpayload/libc/malloc.c')
-rw-r--r--payloads/libpayload/libc/malloc.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/payloads/libpayload/libc/malloc.c b/payloads/libpayload/libc/malloc.c
index 7099e47ed4..b7ac1a7c60 100644
--- a/payloads/libpayload/libc/malloc.c
+++ b/payloads/libpayload/libc/malloc.c
@@ -366,7 +366,7 @@ static struct align_region_t *allocate_region(int alignment, int num_elements,
if (r == NULL)
return NULL;
- memset(r, 0, sizeof(r));
+ memset(r, 0, sizeof(*r));
if (num_elements != 0) {
r->alignment = alignment;