Skip to content

Commit ff0ae9b

Browse files
vitalybukastefanseefeld
authored andcommitted
dynamic_cast before destructor
Call to the destructor ends lifetime of the object, including vptr used by dynamic_cast.
1 parent b988d70 commit ff0ae9b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/object/class.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,9 @@ namespace objects
333333
for (instance_holder* p = kill_me->objects, *next; p != 0; p = next)
334334
{
335335
next = p->next();
336+
void* q = dynamic_cast<void*>(p);
336337
p->~instance_holder();
337-
instance_holder::deallocate(inst, dynamic_cast<void*>(p));
338+
instance_holder::deallocate(inst, q);
338339
}
339340

340341
// Python 2.2.1 won't add weak references automatically when

0 commit comments

Comments
 (0)