diff options
author | Henry Castro <hcastro@collabora.com> | 2020-12-04 17:00:51 -0400 |
---|---|---|
committer | Henry Castro <hcastro@collabora.com> | 2020-12-18 18:20:56 +0100 |
commit | ca839b341883c1238f27ba42236f08ebb49d53a4 (patch) | |
tree | 8e37b1f872e8f615095e89a49ecc1fbff1c8863d /vcl/jsdialog | |
parent | 40588ede2070e5b01ad4d2c71894bd19d6ec9738 (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>
Diffstat (limited to 'vcl/jsdialog')
-rw-r--r-- | vcl/jsdialog/jsdialogbuilder.cxx | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index e4dd0f4a8b96..795acc644274 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -383,33 +383,35 @@ VclPtr<vcl::Window>& JSInstanceBuilder::GetNotifierWindow() std::unique_ptr<weld::Dialog> JSInstanceBuilder::weld_dialog(const OString& id) { + std::unique_ptr<weld::Dialog> pRet; ::Dialog* pDialog = m_xBuilder->get<::Dialog>(id); - m_nWindowId = pDialog->GetLOKWindowId(); - pDialog->SetLOKTunnelingState(false); - - InsertWindowToMap(m_nWindowId); if (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") - { - tools::JsonWriter aJsonWriter; - m_aOwnedToplevel->DumpAsPropertyTree(aJsonWriter); - aJsonWriter.put("id", m_aOwnedToplevel->GetLOKWindowId()); - pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, aJsonWriter.extractData()); + const vcl::ILibreOfficeKitNotifier* pNotifier = pDialog->GetLOKNotifier(); + if (pNotifier && id != "MacroSelectorDialog") + { + tools::JsonWriter aJsonWriter; + m_aOwnedToplevel->DumpAsPropertyTree(aJsonWriter); + aJsonWriter.put("id", m_aOwnedToplevel->GetLOKWindowId()); + pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, aJsonWriter.extractData()); + } } return pRet; |