Resolves: tdf#133862 crash in customize toolbar in embedded math

Change-Id: I2fc7f3620145e48516c3ca73c0a5d08dce11d78a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96034
Tested-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/cui/source/customize/SvxNotebookbarConfigPage.cxx b/cui/source/customize/SvxNotebookbarConfigPage.cxx
index 584767d..0fb0567 100644
--- a/cui/source/customize/SvxNotebookbarConfigPage.cxx
+++ b/cui/source/customize/SvxNotebookbarConfigPage.cxx
@@ -418,6 +418,8 @@ void SvxNotebookbarConfigPage::SelectElement()
    OString sUIFileUIPath = CustomNotebookbarGenerator::getSystemPath(
        CustomNotebookbarGenerator::getCustomizedUIPath());
    xmlDocPtr pDoc = xmlParseFile(sUIFileUIPath.getStr());
    if (!pDoc)
        return;
    xmlNodePtr pNodePtr = xmlDocGetRootElement(pDoc);

    std::vector<NotebookbarEntries> aEntries;
@@ -479,10 +481,7 @@ void SvxNotebookbarConfigPage::SelectElement()

    aEntries.clear();

    if (pDoc != nullptr)
    {
        xmlFreeDoc(pDoc);
    }
    xmlFreeDoc(pDoc);
}

SvxNotebookbarEntriesListBox::SvxNotebookbarEntriesListBox(std::unique_ptr<weld::TreeView> xParent,