Further explanation of the name issue is ok, let me explain my scenario.
I have a container of a list of pointers to several objects on the heap. Whenever a new object is created, the pointer to it is added to the list and whenever the object is deleted, its pointer is deleted. It is safe to say that all pointers in this list are always valid.
Many objects in the list contain pointers to other objects in the same list.
Before casting any of these pointers, I would like to use the CheckAgainstList(ptr*) function to make sure that one object points to another object in the same list and therefore does not point to the object that has since been deleted.
Get your tinfoil hats now, is this possible?
- Object A has a pointer to object B with a memory address of
0x00988e50 . - Object B is deleted.
- Object C is created and placed in the newly freed memory space
0x00988e50 . CheckAgainstList(ptr*) returns true when we check the pointer, because the object C is in the list and is in the same memory address that was used by B.
Now we have a mistake, because A thinks she has a pointer to B, but B is gone, and C took his place to speak.
Is this potential error possible?
source share