kernel/util: Clear list links on removal under KDEBUG.

This way, if someone tries to double-remove an item or do other
invalid things to it, this will crash instead of (silently) corrupting.
This commit is contained in:
Augustin Cavalier 2023-03-30 12:46:31 -04:00
parent 2393d22cdb
commit ff6e777d28
2 changed files with 9 additions and 1 deletions

View File

@ -528,6 +528,10 @@ DOUBLY_LINKED_LIST_CLASS_NAME::Remove(Element* element)
sGetLink(elLink->next)->previous = elLink->previous;
else
fLast = elLink->previous;
#if DEBUG_DOUBLY_LINKED_LIST
elLink->next = elLink->previous = NULL;
#endif
}
}

View File

@ -76,9 +76,13 @@ void
list_remove_link(void *_link)
{
list_link *link = (list_link *)_link;
link->next->prev = link->prev;
link->prev->next = link->next;
#if DEBUG_DOUBLY_LINKED_LIST
link->prev = link->next = NULL;
#endif
}