vcl/jsdialog/jsdialogbuilder.cxx |   34 ++++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)

New commits:
commit ca839b341883c1238f27ba42236f08ebb49d53a4
Author:     Henry Castro <hcas...@collabora.com>
AuthorDate: Fri Dec 4 17:00:51 2020 -0400
Commit:     Henry Castro <hcas...@collabora.com>
CommitDate: Fri Dec 18 18:20:56 2020 +0100

    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 <hcas...@collabora.com>

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;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to