Files
codeql/cpp/ql/test/query-tests/jsf/4.10 Classes/AV Rule 79/QObject.cpp
Owen Mansel-Chan 76d8ae8694 Add MISSING: tag
2026-07-07 10:59:21 +01:00

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);
}
};