[graphics/okular] core/script: fix(script): remove double-free in JSApp::alert()
Albert Astals Cid <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit ba5a33589431dc19f5d89e7d60b376ff01b66ae5 by Albert Astals Cid, on behalf of zhang shoucheng.
Committed on 18/07/2026 at 16:35.
Pushed by aacid into branch 'master'.
fix(script): remove double-free in JSApp::alert()
QMessageBox::setCheckBox() takes ownership of the checkbox widget.
When the QMessageBox is destroyed at the end of alert(), it deletes
the checkbox via Qt's object tree. The manual 'delete checkBox' on
line 251 causes a double-free, leading to a deterministic crash
(SIGABRT) whenever a PDF triggers app.alert() with a checkbox.
Remove the erroneous manual delete and add a comment explaining
ownership.
M +2 -1 core/script/js_app.cpp
https://invent.kde.org/graphics/okular/-/commit/ba5a33589431dc19f5d89e7d60b376ff01b66ae5
diff --git a/core/script/js_app.cpp b/core/script/js_app.cpp
index 001ba316a..423fe68af 100644
--- a/core/script/js_app.cpp
+++ b/core/script/js_app.cpp
@@ -248,7 +248,8 @@ int JSApp::alert(const QString &cMsg, int nIcon, int nType, const QString &cTitl
QJSValue(oCheckbox).setProperty(QStringLiteral("bAfterValue"), checkBox->isChecked());
}
- delete checkBox;
+ // checkBox is owned by QMessageBox (via setCheckBox) and will be
+ // deleted when 'box' goes out of scope. Do not delete it here.
return ret;
}