[graphics/okular/release/26.08] 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 3cadb2aad020aa5ccf381bba0f9ed8126a9779c8 by Albert Astals Cid, on behalf of zhang shoucheng.
Committed on 18/07/2026 at 23:46.
Pushed by aacid into branch 'release/26.08'.
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.
(cherry picked from commit ba5a33589431dc19f5d89e7d60b376ff01b66ae5)
M +2 -1 core/script/js_app.cpp
https://invent.kde.org/graphics/okular/-/commit/3cadb2aad020aa5ccf381bba0f9ed8126a9779c8
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;
}