tdf#135639: check the return value of GetDim32

... to avoid crash accessing non-existing element of pChildItem->vIndices

Change-Id: I248a9301abd69883f940051d9d9671298dcc8453
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100540
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
Mike Kaganski
2020-08-11 18:11:10 +03:00
parent 98665425eb
commit b71815a8d4

View File

@@ -2128,7 +2128,8 @@ IMPL_LINK(WatchWindow, RequestingChildrenHdl, const weld::TreeIter&, rParent, bo
int nParentLevel = bArrayIsRootArray ? pItem->nDimLevel : 0; int nParentLevel = bArrayIsRootArray ? pItem->nDimLevel : 0;
int nThisLevel = nParentLevel + 1; int nThisLevel = nParentLevel + 1;
sal_Int32 nMin, nMax; sal_Int32 nMin, nMax;
pArray->GetDim32( nThisLevel, nMin, nMax ); if (pArray->GetDim32(nThisLevel, nMin, nMax))
{
for (sal_Int32 i = nMin; i <= nMax; i++) for (sal_Int32 i = nMin; i <= nMax; i++)
{ {
WatchItem* pChildItem = new WatchItem(pItem->maName); WatchItem* pChildItem = new WatchItem(pItem->maName);
@@ -2160,12 +2161,14 @@ IMPL_LINK(WatchWindow, RequestingChildrenHdl, const weld::TreeIter&, rParent, bo
OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pChildItem))); OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pChildItem)));
m_xTreeListBox->insert(&rParent, -1, &aDisplayName, &sId, nullptr, nullptr, false, xRet.get()); m_xTreeListBox->insert(&rParent, -1, &aDisplayName, &sId, nullptr, nullptr, false,
xRet.get());
m_xTreeListBox->set_text(*xRet, "", 1); m_xTreeListBox->set_text(*xRet, "", 1);
m_xTreeListBox->set_text(*xRet, "", 2); m_xTreeListBox->set_text(*xRet, "", 2);
nElementCount++; nElementCount++;
} }
}
if (nElementCount > 0 && !m_nUpdateWatchesId) if (nElementCount > 0 && !m_nUpdateWatchesId)
{ {
m_nUpdateWatchesId = Application::PostUserEvent(LINK(this, WatchWindow, ExecuteUpdateWatches)); m_nUpdateWatchesId = Application::PostUserEvent(LINK(this, WatchWindow, ExecuteUpdateWatches));