From 32446b36030e5261dcaeddd0c26d32588e97b4db Mon Sep 17 00:00:00 2001 From: Mathieu Maret Date: Fri, 9 Apr 2021 20:47:20 +0200 Subject: [PATCH] Correct NULL access --- tests/test.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test.c b/tests/test.c index 41e80a9..04fb767 100644 --- a/tests/test.c +++ b/tests/test.c @@ -125,7 +125,8 @@ static void testPaging(void) } printf("%d pages allocated\n", allocCount); - while ((page = list_pop_head(allocated_page_list)) != NULL) { + while (!list_is_empty(allocated_page_list) && + (page = list_pop_head(allocated_page_list)) != NULL) { assertmsg((char)page->phy_addr == (char)freeCount, "page modified %d but is %d\n", freeCount, page->phy_addr); assertmsg(unrefPhyPage((ulong)page) >= 0, "Failed to free page %d\n", (ulong)page); @@ -326,7 +327,7 @@ void run_test(void) char *strAlloc; int ret = asprintf(&strAlloc, "hello %s\n", "world"); printf("asprint ret %d %s\n", ret, strAlloc); - assert(ret == 13); //include the '\0' + assert(ret == 13); // include the '\0' free(strAlloc); } testPaging();