summaryrefslogtreecommitdiffstats
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-14 08:31:01 +0200
commit0f3d1a154b18753a93a075b0be089c43bfcc9424 (patch)
tree39c30563d0949683dc709dcd68c28762d98ed220 /basctl
parentAvoid one more unhelpful -Werror=stringop-truncation (diff)
downloadcore-0f3d1a154b18753a93a075b0be089c43bfcc9424.tar.gz
core-0f3d1a154b18753a93a075b0be089c43bfcc9424.zip
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> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100565 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org> Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100615 Reviewed-by: Michael Stahl <michael.stahl@cib.de> (cherry picked from commit 575f4ec1dcb0a2dbd80bfaf001a5fc3072cd11fa) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100695 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Diffstat (limited to 'basctl')
-rw-r--r--basctl/source/basicide/baside2b.cxx60
1 files changed, 31 insertions, 29 deletions
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index d07222a44d27..c4d1f1e44b04 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -2188,39 +2188,41 @@ void WatchTreeListBox::RequestingChildren( SvTreeListEntry * pParent )
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++ )
- {
- short n = pChildItem->vIndices[j] = pItem->vIndices[j];
- aIndexStr.append(OUString::number( n )).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++ )
+ {
+ short n = pChildItem->vIndices[j] = pItem->vIndices[j];
+ aIndexStr.append(OUString::number( n )).append(",");
+ }
+ pChildItem->vIndices[nParentLevel] = sal::static_int_cast<short>( 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;
+
+ SvTreeListEntry* pChildEntry = SvTreeListBox::InsertEntry( aDisplayName, pEntry );
+ nElementCount++;
+ pChildEntry->SetUserData( pChildItem );
}
- pChildItem->vIndices[nParentLevel] = sal::static_int_cast<short>( 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;
-
- SvTreeListEntry* pChildEntry = SvTreeListBox::InsertEntry( aDisplayName, pEntry );
- nElementCount++;
- pChildEntry->SetUserData( pChildItem );
}
if( nElementCount > 0 )
{