From ac7410a726a7269dcaef4c80061cab7a4447f6d1 Mon Sep 17 00:00:00 2001 From: suvendhu Date: Wed, 14 Jun 2023 14:51:26 +0530 Subject: [PATCH] memory handling improvement --- common.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/common.c b/common.c index 42e0fc7..0e80bca 100755 --- a/common.c +++ b/common.c @@ -677,8 +677,10 @@ void icwmp_free(void *m) return; struct cwmp_mem *rm; rm = container_of(m, struct cwmp_mem, mem); - list_del(&rm->list); - free(rm); + if (rm != NULL) { + list_del(&rm->list); + free(rm); + } } void icwmp_cleanmem() @@ -686,8 +688,10 @@ void icwmp_cleanmem() struct cwmp_mem *mem; while (cwmp_memory_list.next != &cwmp_memory_list) { mem = list_entry(cwmp_memory_list.next, struct cwmp_mem, list); - list_del(&mem->list); - free(mem); + if (mem != NULL) { + list_del(&mem->list); + free(mem); + } } }