summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorHenry Castro <hcastro@collabora.com>2020-12-04 17:00:51 -0400
committerHenry Castro <hcastro@collabora.com>2021-01-18 21:43:57 +0100
commit668fe5ba93a80f3949d0747917f74292a2606215 (patch)
treeec44d4b66b9148f0730ecb7b3c422c9eb65e623b /vcl
parent5780fcc21f8f1ed9409eff2b82b7c33e54ed8542 (diff)
lok: jsdialog: fix possible nullptr dereference
p = nullptr; if (p) { } p->Somenthing(); Change-Id: I2a46d6a8e7eae96928210c8941ec71eed88bf631 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107245 Tested-by: Jenkins Reviewed-by: Henry Castro <hcastro@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109136 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/jsdialog/jsdialogbuilder.cxx38
1 files changed, 20 insertions, 18 deletions
diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx
index 649893bb6832..49cbac450087 100644
--- a/vcl/jsdialog/jsdialogbuilder.cxx
+++ b/vcl/jsdialog/jsdialogbuilder.cxx
@@ -375,35 +375,37 @@ VclPtr<vcl::Window>& JSInstanceBuilder::GetNotifierWindow()
std::unique_ptr<weld::Dialog> JSInstanceBuilder::weld_dialog(const OString& id, bool bTakeOwnership)
{
+ std::unique_ptr<weld::Dialog> pRet;
::Dialog* pDialog = m_xBuilder->get<::Dialog>(id);
- m_nWindowId = pDialog->GetLOKWindowId();
- pDialog->SetLOKTunnelingState(false);
-
- InsertWindowToMap(m_nWindowId);
if (bTakeOwnership && pDialog)
{
+ m_nWindowId = pDialog->GetLOKWindowId();
+ pDialog->SetLOKTunnelingState(false);
+
+ InsertWindowToMap(m_nWindowId);
+
assert(!m_aOwnedToplevel && "only one toplevel per .ui allowed");
m_aOwnedToplevel.set(pDialog);
m_xBuilder->drop_ownership(pDialog);
m_bHasTopLevelDialog = true;
- }
- std::unique_ptr<weld::Dialog> pRet(pDialog ? new JSDialog(m_aOwnedToplevel, m_aOwnedToplevel,
- pDialog, this, false, m_sTypeOfJSON)
- : nullptr);
+ pRet.reset(pDialog ? new JSDialog(m_aOwnedToplevel, m_aOwnedToplevel, pDialog, this, false,
+ m_sTypeOfJSON)
+ : nullptr);
- RememberWidget("__DIALOG__", pRet.get());
+ RememberWidget("__DIALOG__", pRet.get());
- const vcl::ILibreOfficeKitNotifier* pNotifier = pDialog->GetLOKNotifier();
- if (pNotifier && id != "MacroSelectorDialog")
- {
- std::stringstream aStream;
- boost::property_tree::ptree aTree = m_aOwnedToplevel->DumpAsPropertyTree();
- aTree.put("id", m_aOwnedToplevel->GetLOKWindowId());
- boost::property_tree::write_json(aStream, aTree);
- const std::string message = aStream.str();
- pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, message.c_str());
+ const vcl::ILibreOfficeKitNotifier* pNotifier = pDialog->GetLOKNotifier();
+ if (pNotifier && id != "MacroSelectorDialog")
+ {
+ std::stringstream aStream;
+ boost::property_tree::ptree aTree = m_aOwnedToplevel->DumpAsPropertyTree();
+ aTree.put("id", m_aOwnedToplevel->GetLOKWindowId());
+ boost::property_tree::write_json(aStream, aTree);
+ const std::string message = aStream.str();
+ pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, message.c_str());
+ }
}
return pRet;