summaryrefslogtreecommitdiff
path: root/basctl
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2020-08-11 18:11:10 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2020-08-11 21:37:04 +0200
commitb71815a8d49f95657ce8253434187827e63a5ade (patch)
tree9fc0364179b7bce090953ce3e8740e09cfc5249f /basctl
parent98665425ebb5cdeeda341336871ca4da7f4842b7 (diff)
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>
Diffstat (limited to 'basctl')
-rw-r--r--basctl/source/basicide/baside2b.cxx63
1 files changed, 33 insertions, 30 deletions
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index e13656ee73a7..7771b8acff3e 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -2128,43 +2128,46 @@ IMPL_LINK(WatchWindow, RequestingChildrenHdl, const weld::TreeIter&, rParent, bo
int nParentLevel = bArrayIsRootArray ? pItem->nDimLevel : 0;
int nThisLevel = nParentLevel + 1;
sal_Int32 nMin, nMax;
- pArray->GetDim32( nThisLevel, nMin, nMax );
- for( sal_Int32 i = nMin ; i <= nMax ; i++ )
+ if (pArray->GetDim32(nThisLevel, nMin, nMax))
{
- WatchItem* pChildItem = new WatchItem(pItem->maName);
+ for (sal_Int32 i = nMin; i <= nMax; i++)
+ {
+ WatchItem* pChildItem = new WatchItem(pItem->maName);
- // Copy data and create name
+ // Copy data and create name
- OUStringBuffer aIndexStr = "(";
- pChildItem->mpArrayParentItem = pItem;
- pChildItem->nDimLevel = nThisLevel;
- pChildItem->nDimCount = pItem->nDimCount;
- pChildItem->vIndices.resize(pChildItem->nDimCount);
- sal_Int32 j;
- for( j = 0 ; j < nParentLevel ; j++ )
- {
- sal_Int32 n = pChildItem->vIndices[j] = pItem->vIndices[j];
- aIndexStr.append(OUString::number( n )).append(",");
- }
- pChildItem->vIndices[nParentLevel] = i;
- aIndexStr.append(OUString::number( i )).append(")");
+ OUStringBuffer aIndexStr = "(";
+ pChildItem->mpArrayParentItem = pItem;
+ pChildItem->nDimLevel = nThisLevel;
+ pChildItem->nDimCount = pItem->nDimCount;
+ pChildItem->vIndices.resize(pChildItem->nDimCount);
+ sal_Int32 j;
+ for (j = 0; j < nParentLevel; j++)
+ {
+ sal_Int32 n = pChildItem->vIndices[j] = pItem->vIndices[j];
+ aIndexStr.append(OUString::number(n)).append(",");
+ }
+ pChildItem->vIndices[nParentLevel] = i;
+ aIndexStr.append(OUString::number(i)).append(")");
- OUString aDisplayName;
- WatchItem* pArrayRootItem = pChildItem->GetRootItem();
- if( pArrayRootItem && pArrayRootItem->mpArrayParentItem )
- aDisplayName = pItem->maDisplayName;
- else
- aDisplayName = pItem->maName;
- aDisplayName += aIndexStr;
- pChildItem->maDisplayName = aDisplayName;
+ OUString aDisplayName;
+ WatchItem* pArrayRootItem = pChildItem->GetRootItem();
+ if (pArrayRootItem && pArrayRootItem->mpArrayParentItem)
+ aDisplayName = pItem->maDisplayName;
+ else
+ aDisplayName = pItem->maName;
+ aDisplayName += aIndexStr;
+ pChildItem->maDisplayName = aDisplayName;
- 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->set_text(*xRet, "", 1);
- m_xTreeListBox->set_text(*xRet, "", 2);
+ m_xTreeListBox->insert(&rParent, -1, &aDisplayName, &sId, nullptr, nullptr, false,
+ xRet.get());
+ m_xTreeListBox->set_text(*xRet, "", 1);
+ m_xTreeListBox->set_text(*xRet, "", 2);
- nElementCount++;
+ nElementCount++;
+ }
}
if (nElementCount > 0 && !m_nUpdateWatchesId)
{