summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2018-10-21 14:00:13 +0200
committerMike Kaganski <mike.kaganski@collabora.com>2018-10-21 15:24:15 +0200
commit33a8afeda6e1b6325f42790a0e1cc3c6cca8409f (patch)
tree45f9425cad1a060b5133809edf30660ff546944e
parent96762d29bc796bebdd513352aabcad3b216f847d (diff)
V668 There is no sense in testing the 'pBuf' pointer against null, as the memory was allocated using the 'new' operator. The exception will be generated in the case of memory allocation error. V547 Expression 'ePageKind == PPT_NOTEPAGE' is always true. V581 The conditional expressions of the 'if' statements situated alongside each other are identical. Check lines: 3724, 3727. V1023 A pointer without owner is added to the 'aCharPropList' container by the 'emplace_back' method. A memory leak will occur in case of an exception. Change-Id: I5edae28a6ca1023a512fd5f86208951d439db941 Reviewed-on: https://gerrit.libreoffice.org/62131 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r--filter/source/msfilter/svdfppt.cxx43
1 files changed, 22 insertions, 21 deletions
diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx
index 687943db3950..581788294902 100644
--- a/filter/source/msfilter/svdfppt.cxx
+++ b/filter/source/msfilter/svdfppt.cxx
@@ -2079,15 +2079,12 @@ void SdrPowerPointImport::SeekOle( SfxObjectShell* pShell, sal_uInt32 nFilterOpt
sal_uInt32 nToCopy, nBufSize;
nToCopy = pHd->nRecLen;
std::unique_ptr<sal_uInt8[]> pBuf(new sal_uInt8[ 0x40000 ]); // 256KB Buffer
- if ( pBuf )
+ while ( nToCopy )
{
- while ( nToCopy )
- {
- nBufSize = ( nToCopy >= 0x40000 ) ? 0x40000 : nToCopy;
- rStCtrl.ReadBytes(pBuf.get(), nBufSize);
- xOriginal->WriteBytes(pBuf.get(), nBufSize);
- nToCopy -= nBufSize;
- }
+ nBufSize = ( nToCopy >= 0x40000 ) ? 0x40000 : nToCopy;
+ rStCtrl.ReadBytes(pBuf.get(), nBufSize);
+ xOriginal->WriteBytes(pBuf.get(), nBufSize);
+ nToCopy -= nBufSize;
}
}
}
@@ -2203,12 +2200,15 @@ bool SdrPowerPointImport::ReadFontCollection()
PptSlidePersistList* SdrPowerPointImport::GetPageList(PptPageKind ePageKind) const
{
- if ( ePageKind == PPT_MASTERPAGE )
- return m_pMasterPages.get();
- if ( ePageKind == PPT_SLIDEPAGE )
- return m_pSlidePages.get();
- if ( ePageKind == PPT_NOTEPAGE )
- return m_pNotePages.get();
+ switch (ePageKind)
+ {
+ case PPT_MASTERPAGE:
+ return m_pMasterPages.get();
+ case PPT_SLIDEPAGE:
+ return m_pSlidePages.get();
+ case PPT_NOTEPAGE:
+ return m_pNotePages.get();
+ }
return nullptr;
}
@@ -3723,10 +3723,8 @@ bool PPTNumberFormatCreator::GetNumberFormat( SdrPowerPointImport const & rManag
if ( rNumberFormat.GetNumberingType() != SVX_NUM_BITMAP )
pParaObj->UpdateBulletRelSize( nBulletHeight );
if ( nHardCount )
- ImplGetNumberFormat( rManager, rNumberFormat );
-
- if ( nHardCount )
{
+ ImplGetNumberFormat( rManager, rNumberFormat );
switch ( rNumberFormat.GetNumberingType() )
{
case SVX_NUM_CHARS_UPPER_LETTER :
@@ -5295,7 +5293,7 @@ void PPTStyleTextPropReader::Init( SvStream& rIn, const DffRecordHeader& rTextHe
bTextPropAtom, nExtParaPos, aStyleTextProp9, nExtParaFlags,
nBuBlip, nHasAnm, nAnmScheme );
- aCharPropList.emplace_back( new PPTCharPropSet( aCharPropSet, 0 ) );
+ aCharPropList.push_back(o3tl::make_unique<PPTCharPropSet>(aCharPropSet, 0));
}
}
@@ -5356,7 +5354,8 @@ void PPTStyleTextPropReader::Init( SvStream& rIn, const DffRecordHeader& rTextHe
else if ( bEmptyParaPossible )
aCharPropSet.maString.clear();
if ( nLen || bEmptyParaPossible )
- aCharPropList.emplace_back( new PPTCharPropSet( aCharPropSet, nCurrentPara ) );
+ aCharPropList.push_back(
+ o3tl::make_unique<PPTCharPropSet>(aCharPropSet, nCurrentPara));
nCurrentPara++;
nLen++;
nCharReadCnt += nLen;
@@ -5369,7 +5368,8 @@ void PPTStyleTextPropReader::Init( SvStream& rIn, const DffRecordHeader& rTextHe
{
nLen = ( nCurrentSpecMarker & 0xffff ) - nCharReadCnt;
aCharPropSet.maString = aString.copy(nCharReadCnt, nLen);
- aCharPropList.emplace_back( new PPTCharPropSet( aCharPropSet, nCurrentPara ) );
+ aCharPropList.push_back(
+ o3tl::make_unique<PPTCharPropSet>(aCharPropSet, nCurrentPara));
nCharCount -= nLen;
nCharReadCnt += nLen;
}
@@ -5396,7 +5396,8 @@ void PPTStyleTextPropReader::Init( SvStream& rIn, const DffRecordHeader& rTextHe
nStrLen = nMaxStrLen;
aCharPropSet.maString = aString.copy(nCharReadCnt, nStrLen);
}
- aCharPropList.emplace_back( new PPTCharPropSet( aCharPropSet, nCurrentPara ) );
+ aCharPropList.push_back(
+ o3tl::make_unique<PPTCharPropSet>(aCharPropSet, nCurrentPara));
nCharReadCnt += nCharCount;
bEmptyParaPossible = false;
break;