Skip to content

Commit

Permalink
Fix the PList not always correctly cleaning up entries causing PList …
Browse files Browse the repository at this point in the history
…corruption.
  • Loading branch information
daid committed Oct 3, 2023
1 parent 582dc3e commit bb9467e
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/pointerList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ _PListEntry* _PListBase::removeEntry(_PListEntry* e)
_PListEntry* next = e->object_next;
if (next)
next->object_prev = e->object_prev;
if (e->object_prev)
if (e->object_prev) {
e->object_prev->object_next = next;
else
} else {
e->object->pointer_list_entry_list_start = next;
}

next = e->list_next;
if (next)
Expand All @@ -67,6 +68,13 @@ void _PListEntry::free()
{
list_next = free_list;
free_list = this;
#ifdef DEBUG
object = nullptr;
object_prev = nullptr;
object_next = nullptr;

list = nullptr;
#endif
}

_PListEntry* _PListEntry::create()
Expand All @@ -89,6 +97,8 @@ void _PListBase::insert(AutoPointerObject* item)
new_entry->object = item;
new_entry->object_prev = nullptr;
new_entry->object_next = new_entry->object->pointer_list_entry_list_start;
if (new_entry->object_next)
new_entry->object_next->object_prev = new_entry;
new_entry->object->pointer_list_entry_list_start = new_entry;

new_entry->list = this;
Expand Down

0 comments on commit bb9467e

Please sign in to comment.