summaryrefslogtreecommitdiff
path: root/basic
diff options
context:
space:
mode:
authorLaurent Godard <lgodard.libre@laposte.net>2015-08-18 13:40:42 +0200
committerCaolán McNamara <caolanm@redhat.com>2015-08-18 12:16:29 +0000
commit6e403346634113f7b5d582774864baa4555b2843 (patch)
treeddbe84f5a3f9ea555977e3ceb01cb36d7641098d /basic
parentb28a2cb6823eeb9fefaa3432858fb3319e8b8bb3 (diff)
null pointer guard if no user defined types declared at the module level
Change-Id: I368a168c636e4029e9cd9bbe4a4df5d9b846c923 Reviewed-on: https://gerrit.libreoffice.org/17834 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'basic')
-rw-r--r--basic/source/classes/image.cxx103
1 files changed, 53 insertions, 50 deletions
diff --git a/basic/source/classes/image.cxx b/basic/source/classes/image.cxx
index bc6fa3a54919..ef468dc2e5a1 100644
--- a/basic/source/classes/image.cxx
+++ b/basic/source/classes/image.cxx
@@ -443,79 +443,82 @@ bool SbiImage::Save( SvStream& r, sal_uInt32 nVer )
SbiCloseRecord( r, nPos );
}
// User defined types
- sal_uInt16 nTypes = rTypes->Count();
- if (nTypes > 0 )
+ if (rTypes)
{
- nPos = SbiOpenRecord( r, B_SBXOBJECTS, nTypes );
-
- for (sal_uInt16 i = 0; i < nTypes; i++)
+ sal_uInt16 nTypes = rTypes->Count();
+ if (nTypes > 0 )
{
- SbxObject* pType = static_cast< SbxObject* > ( rTypes->Get(i) );
- OUString aTypeName = pType->GetClassName();
+ nPos = SbiOpenRecord( r, B_SBXOBJECTS, nTypes );
- r.WriteUniOrByteString( aTypeName, eCharSet );
+ for (sal_uInt16 i = 0; i < nTypes; i++)
+ {
+ SbxObject* pType = static_cast< SbxObject* > ( rTypes->Get(i) );
+ OUString aTypeName = pType->GetClassName();
- SbxArray *pTypeMembers = pType->GetProperties();
- sal_uInt16 nTypeMembers = pTypeMembers->Count();
+ r.WriteUniOrByteString( aTypeName, eCharSet );
- r.WriteInt16(nTypeMembers);
+ SbxArray *pTypeMembers = pType->GetProperties();
+ sal_uInt16 nTypeMembers = pTypeMembers->Count();
- for (sal_uInt16 j = 0; j < nTypeMembers; j++)
- {
+ r.WriteInt16(nTypeMembers);
- SbxProperty* pTypeElem = static_cast< SbxProperty* > ( pTypeMembers->Get(j) );
+ for (sal_uInt16 j = 0; j < nTypeMembers; j++)
+ {
- OUString aElemName = pTypeElem->GetName();
- r.WriteUniOrByteString( aElemName, eCharSet );
+ SbxProperty* pTypeElem = static_cast< SbxProperty* > ( pTypeMembers->Get(j) );
- SbxDataType dataType = pTypeElem->GetType();
- r.WriteInt16(dataType);
+ OUString aElemName = pTypeElem->GetName();
+ r.WriteUniOrByteString( aElemName, eCharSet );
- SbxFlagBits nElemFlags = pTypeElem->GetFlags();
- r.WriteUInt32(static_cast< sal_uInt32 > (nElemFlags) );
+ SbxDataType dataType = pTypeElem->GetType();
+ r.WriteInt16(dataType);
- SbxBase* pElemObject = pTypeElem->GetObject();
+ SbxFlagBits nElemFlags = pTypeElem->GetFlags();
+ r.WriteUInt32(static_cast< sal_uInt32 > (nElemFlags) );
- if (pElemObject)
- {
- r.WriteInt16(1); // has elem Object
+ SbxBase* pElemObject = pTypeElem->GetObject();
- if( dataType == SbxOBJECT )
+ if (pElemObject)
{
- // nested user defined types
- // declared before use, so it is ok to reference it by name on load
- SbxObject* pNestedType = static_cast< SbxObject* > ( pElemObject );
- r.WriteUniOrByteString( pNestedType->GetClassName(), eCharSet );
- }
- else
- {
- // an array
- SbxDimArray* pArray = static_cast< SbxDimArray* > ( pElemObject );
+ r.WriteInt16(1); // has elem Object
- bool bFixedSize = pArray->hasFixedSize();
- if (bFixedSize)
- r.WriteInt16(1);
+ if( dataType == SbxOBJECT )
+ {
+ // nested user defined types
+ // declared before use, so it is ok to reference it by name on load
+ SbxObject* pNestedType = static_cast< SbxObject* > ( pElemObject );
+ r.WriteUniOrByteString( pNestedType->GetClassName(), eCharSet );
+ }
else
- r.WriteInt16(0);
+ {
+ // an array
+ SbxDimArray* pArray = static_cast< SbxDimArray* > ( pElemObject );
- sal_Int32 nDims = pArray->GetDims();
- r.WriteInt32(nDims);
+ bool bFixedSize = pArray->hasFixedSize();
+ if (bFixedSize)
+ r.WriteInt16(1);
+ else
+ r.WriteInt16(0);
- for (sal_Int32 d = 0; d < nDims; d++)
- {
- sal_Int32 lBound;
- sal_Int32 uBound;
- pArray->GetDim32(d, lBound, uBound);
- r.WriteInt32(lBound).WriteInt32(uBound);
+ sal_Int32 nDims = pArray->GetDims();
+ r.WriteInt32(nDims);
+
+ for (sal_Int32 d = 0; d < nDims; d++)
+ {
+ sal_Int32 lBound;
+ sal_Int32 uBound;
+ pArray->GetDim32(d, lBound, uBound);
+ r.WriteInt32(lBound).WriteInt32(uBound);
+ }
}
}
- }
- else
- r.WriteInt16(0); // no elem Object
+ else
+ r.WriteInt16(0); // no elem Object
+ }
}
+ SbiCloseRecord( r, nPos );
}
- SbiCloseRecord( r, nPos );
}
// Set overall length
SbiCloseRecord( r, nStart );