Skip to content

Commit

Permalink
dynamic_cast before destructor
Browse files Browse the repository at this point in the history
Call to the destructor ends lifetime of the object, including vptr
used by dynamic_cast.
  • Loading branch information
vitalybuka authored and stefanseefeld committed Sep 22, 2024
1 parent b988d70 commit ff0ae9b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/object/class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,9 @@ namespace objects
for (instance_holder* p = kill_me->objects, *next; p != 0; p = next)
{
next = p->next();
void* q = dynamic_cast<void*>(p);
p->~instance_holder();
instance_holder::deallocate(inst, dynamic_cast<void*>(p));
instance_holder::deallocate(inst, q);
}

// Python 2.2.1 won't add weak references automatically when
Expand Down

0 comments on commit ff0ae9b

Please sign in to comment.