mirror of
https://github.com/github/codeql.git
synced 2026-08-04 17:33:18 +02:00
26 lines
763 B
C++
26 lines
763 B
C++
struct QObject {
|
|
QObject(QObject *parent);
|
|
void setParent(QObject *parent);
|
|
};
|
|
|
|
struct DerivedFromQObject : public QObject {
|
|
DerivedFromQObject(QObject *parent);
|
|
};
|
|
|
|
class MyQtUser {
|
|
DerivedFromQObject *noParent, *constructorParent, *laterParent;
|
|
|
|
MyQtUser(QObject *parent) {
|
|
// This object sets its parent pointer to null and thus must be deleted
|
|
// manually.
|
|
noParent = new DerivedFromQObject(nullptr); // $ MISSING: Alert // BAD [NOT DETECTED]
|
|
|
|
// This object does not need to be deleted because it will be deleted by
|
|
// its parent object when the time is right.
|
|
constructorParent = new DerivedFromQObject(parent); // GOOD
|
|
|
|
laterParent = new DerivedFromQObject(nullptr); // GOOD
|
|
laterParent->setParent(parent);
|
|
}
|
|
};
|