From cb0858f14f1e8b55dc6201d1104ced1b3e109b2c Mon Sep 17 00:00:00 2001 From: Sara Date: Fri, 26 Jan 2024 12:01:41 +0100 Subject: [PATCH] fix: critical, fixed list_empty not actually freeing the allocated list leading to orphanned memory --- list.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/list.c b/list.c index 6c2bf04..9ce434a 100644 --- a/list.c +++ b/list.c @@ -37,8 +37,8 @@ List list_copy(const List* source) { } void list_empty(List* self) { - if(self->data == NULL || self->cap == 0) - return; + if(self->data != NULL && self->cap != 0) + free(self->data); self->data = NULL; self->cap = 0; self->len = 0;