For example deleting something twice.
int* i = new int;
delete i;
delete i;
int* i = new int;
delete i;
delete i;
To copy to clipboard, switch view to plain text mode
Remember that QObjects take ownership of their children. Here's an example how it could happen with QObjects:
{
a.setParent(&b);
}
{
QObject a;
QObject b;
a.setParent(&b);
}
To copy to clipboard, switch view to plain text mode
First "b" goes out of scope and gets destructed according to normal C++ rules. "b" is a parent of "a" so it will automatically delete "a". Then "a" goes out of scope and gets destructed, but it was already deleted by "b" --> crash.
Bookmarks