Skip to content

Bad alloc/free whe setting PtrList, UPtrList twice

Example code,

PtrList<T> list(2);
list.set(0, ptr0);

// reorder, reorganization etc ...
list.set(0, ptr0update);
list.set(1, ptr1);

The problem being that the second call to list.set(1, ptr1) returns an autoPtr to the old pointer for memory management. This autoPtr contains a managed pointer to ptr1 which will get freed although ptr1 should still be under management of the PtrList.

Change: Setting the PtrList entry to the same pointer address should be a no-op and return a nullptr.