core: fix UAF when calling Qt.quit or Qt.exit

A pointer to the last generation had shutdown() called on it after deletion.
This commit is contained in:
outfoxxed 2024-08-28 15:30:02 -07:00
parent e327d6750d
commit 9967e2e03b
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E
2 changed files with 5 additions and 0 deletions

View file

@ -96,6 +96,7 @@ void RootWrapper::reloadGraph(bool hard) {
generation->onReload(hard ? nullptr : this->generation);
if (hard && this->generation != nullptr) {
QObject::disconnect(this->generation, nullptr, this, nullptr);
this->generation->destroy();
}
@ -103,6 +104,7 @@ void RootWrapper::reloadGraph(bool hard) {
qInfo() << "Configuration Loaded";
QObject::connect(this->generation, &QObject::destroyed, this, &RootWrapper::generationDestroyed);
QObject::connect(
this->generation,
&EngineGeneration::filesChanged,
@ -117,6 +119,8 @@ void RootWrapper::reloadGraph(bool hard) {
}
}
void RootWrapper::generationDestroyed() { this->generation = nullptr; }
void RootWrapper::onWatchFilesChanged() {
auto watchFiles = QuickshellSettings::instance()->watchFiles();
if (this->generation != nullptr) {

View file

@ -19,6 +19,7 @@ public:
void reloadGraph(bool hard);
private slots:
void generationDestroyed();
void onWatchFilesChanged();
void onWatchedFilesChanged();