Hsuan-ting Chen would like Hsuan Ting Chen to review this change.

View Change

libpayload: free: Separate NULL check out for clarity

Separate the validity check of calling free(NULL) for clarity.

BUG=b:168441735
TEST=emerge-puff libpayload

Change-Id: I0dc355553410bbe59e658945fb40c05f5f709380
Signed-off-by: Hsuan Ting Chen <roccochen@chromium.org>
---
M payloads/libpayload/libc/malloc.c
1 file changed, 4 insertions(+), 0 deletions(-)

git pull ssh://review.coreboot.org:29418/coreboot refs/changes/65/45465/1
diff --git a/payloads/libpayload/libc/malloc.c b/payloads/libpayload/libc/malloc.c
index 48bf32e..20f9ef3 100644
--- a/payloads/libpayload/libc/malloc.c
+++ b/payloads/libpayload/libc/malloc.c
@@ -246,6 +246,10 @@
hdrtype_t hdr;
struct memory_type *type = heap;

+ /* No action occurs on NULL. */
+ if (ptr == NULL)
+ return;
+
/* Sanity check. */
if (ptr < type->start || ptr >= type->end) {
type = dma;

To view, visit change 45465. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I0dc355553410bbe59e658945fb40c05f5f709380
Gerrit-Change-Number: 45465
Gerrit-PatchSet: 1
Gerrit-Owner: Hsuan-ting Chen <roccochen@google.com>
Gerrit-Reviewer: Hsuan Ting Chen <roccochen@chromium.org>
Gerrit-MessageType: newchange