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>
This commit is contained in:
parent
2fff2a6e31
commit
a4fbc385e0
|
@ -366,7 +366,7 @@ static struct align_region_t *allocate_region(int alignment, int num_elements,
|
||||||
if (r == NULL)
|
if (r == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
memset(r, 0, sizeof(r));
|
memset(r, 0, sizeof(*r));
|
||||||
|
|
||||||
if (num_elements != 0) {
|
if (num_elements != 0) {
|
||||||
r->alignment = alignment;
|
r->alignment = alignment;
|
||||||
|
|
Loading…
Reference in New Issue