I'm currently working on SR and when navigating between nodes (using the gotoNode function), I fall upon an error for deleting an already deleted pointer...
So maybe it has nothing to do with the ofstack part but here is the problem... the program crashes down after passing two times in this function... first time, it is ok, and second, the delObj gets a valid pointer, the head gets a pointer Null from the header->next, and fatally, the delObj, passes to the Null as well and causes a crash.
I understand that the pointer affectation makes happening to delObj all what is happening to head, but the checking before doesn't seem to handle that...
Is it a problem in ofstack or in the stack content???
Do I have to correct the dcmtk ofstack and recompile?
Code: Select all
/** removes top element from stack.
* precondition: stack not empty.
*/
void base_pop()
{
assert(head!=NULL);
OFStackLinkBase * delObj = head;
head = head->next;
delete delObj; //here deletes null pointer when head->next is null
stackSize--;
}
Honda H engine
________
ultimate fighter