From 790eada639d41cbaf0568241f08ddcb84d3479cd Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Thu, 2 Feb 2023 16:52:42 +0100 Subject: [PATCH] fixed possible segfault in remove_node --- src/core/lib/utils/memory.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/core/lib/utils/memory.c b/src/core/lib/utils/memory.c index 4b02a9b..20bdffa 100644 --- a/src/core/lib/utils/memory.c +++ b/src/core/lib/utils/memory.c @@ -44,10 +44,6 @@ void push_to_list(void *pointer) void remove_node(node_t *node) { - /* - This whole function assumes the node is in the list, so if you use this without pushing it, bad things will happen :) - */ - node_t *buffer_1 = head; node_t *buffer_2; @@ -58,6 +54,8 @@ void remove_node(node_t *node) buffer_1 = buffer_1 -> next; } + if (node != buffer_1) return; //node WASN'T FOUND + if (buffer_1 == head) //node WAS THE FIRST NODE IN THE LIST { //UNLINK