Commit ed4c858c authored by Nikias Bassen's avatar Nikias Bassen

node_list: Fix memory corruption

The corruption occured if you removed the last node from the list
and later add a new node to the list.
parent 567a7496
......@@ -59,7 +59,10 @@ int node_list_add(node_list_t* list, node_t* node) {
node->prev = last;
// Set the next element of our old "last" element
last->next = node;
if (last) {
// but only if the node list is not empty
last->next = node;
}
// Set the lists prev to the new last element
list->end = node;
......@@ -129,6 +132,9 @@ int node_list_remove(node_list_t* list, node_t* node) {
node->prev->next = newnode;
if (newnode) {
newnode->prev = node->prev;
} else {
// last element in the list
list->end = node->prev;
}
} else {
// we just removed the first element
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment