Correct NULL access

This commit is contained in:
Mathieu Maret 2021-04-09 20:47:20 +02:00
parent 1d1ed1ef60
commit 32446b3603

View File

@ -125,7 +125,8 @@ static void testPaging(void)
} }
printf("%d pages allocated\n", allocCount); 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", assertmsg((char)page->phy_addr == (char)freeCount, "page modified %d but is %d\n",
freeCount, page->phy_addr); freeCount, page->phy_addr);
assertmsg(unrefPhyPage((ulong)page) >= 0, "Failed to free page %d\n", (ulong)page); assertmsg(unrefPhyPage((ulong)page) >= 0, "Failed to free page %d\n", (ulong)page);
@ -326,7 +327,7 @@ void run_test(void)
char *strAlloc; char *strAlloc;
int ret = asprintf(&strAlloc, "hello %s\n", "world"); int ret = asprintf(&strAlloc, "hello %s\n", "world");
printf("asprint ret %d %s\n", ret, strAlloc); printf("asprint ret %d %s\n", ret, strAlloc);
assert(ret == 13); //include the '\0' assert(ret == 13); // include the '\0'
free(strAlloc); free(strAlloc);
} }
testPaging(); testPaging();