Remove ListNode from any LinkedList in dtor.
- Issue found in LinkedListTests when running against ASAN since the LinkedList was being destroyed after the Nodes, thereby triggering a RemoveFromList on the root node, but the other nodes were never removed from the list and are dangling pointers. Change-Id: I136abbc5d73c35142990c9fe4669e5fc6d5ef644 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110500 Reviewed-by: Austin Eng <enga@chromium.org> Auto-Submit: Loko Kung <lokokung@google.com> Commit-Queue: Loko Kung <lokokung@google.com> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
parent
9e15952e2d
commit
a88b90a69d
|
@ -116,6 +116,12 @@ class LinkNode {
|
|||
}
|
||||
}
|
||||
|
||||
~LinkNode() {
|
||||
// Remove the node from any list, otherwise there can be outstanding references to the node
|
||||
// even after it has been freed.
|
||||
RemoveFromList();
|
||||
}
|
||||
|
||||
// Insert |this| into the linked list, before |e|.
|
||||
void InsertBefore(LinkNode<T>* e) {
|
||||
this->next_ = e;
|
||||
|
@ -175,13 +181,6 @@ class LinkedList {
|
|||
// and root_->previous() wraps around to the end of the list).
|
||||
LinkedList() : root_(&root_, &root_) {}
|
||||
|
||||
~LinkedList() {
|
||||
// If any LinkNodes still exist in the LinkedList, there will be outstanding references to
|
||||
// root_ even after it has been freed. We should remove root_ from the list to prevent any
|
||||
// future access.
|
||||
root_.RemoveFromList();
|
||||
}
|
||||
|
||||
// Appends |e| to the end of the linked list.
|
||||
void Append(LinkNode<T>* e) { e->InsertBefore(&root_); }
|
||||
|
||||
|
|
Loading…
Reference in New Issue