summaryrefslogtreecommitdiff
path: root/vcl/source
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-02-27 09:02:41 +0000
committerCaolán McNamara <caolanm@redhat.com>2017-02-27 09:03:38 +0000
commite577882476f141d94cede91224805d7a6b009cf7 (patch)
tree7a8e877a4f1f83e2dc4239acdf679007c32240ad /vcl/source
parent4e203ca3915e0cee2e7e02b95e78b3f5a8870098 (diff)
ofz#695 leak in ImplConvertFromSVM1
Change-Id: Ida0d97d9a4e5dfeaf091927c38fa9552a1b87ef6
Diffstat (limited to 'vcl/source')
-rw-r--r--vcl/source/gdi/svmconverter.cxx26
1 files changed, 9 insertions, 17 deletions
diff --git a/vcl/source/gdi/svmconverter.cxx b/vcl/source/gdi/svmconverter.cxx
index eae296fb70c2..b1e3be8957e9 100644
--- a/vcl/source/gdi/svmconverter.cxx
+++ b/vcl/source/gdi/svmconverter.cxx
@@ -33,6 +33,7 @@
#include "svmconverter.hxx"
#include <memory>
+#include <o3tl/make_unique.hxx>
// Inlines
void ImplReadRect( SvStream& rIStm, Rectangle& rRect )
@@ -505,7 +506,7 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf )
}
LineInfo aLineInfo( LineStyle::NONE, 0 );
- ::std::stack< LineInfo* > aLIStack;
+ std::stack<std::unique_ptr<LineInfo>> aLIStack;
ScopedVclPtrInstance< VirtualDevice > aFontVDev;
rtl_TextEncoding eActualCharSet = osl_getThreadTextEncoding();
bool bFatLine = false;
@@ -1163,7 +1164,7 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf )
case GDI_PUSH_ACTION:
{
- aLIStack.push( new LineInfo( aLineInfo ) );
+ aLIStack.push(o3tl::make_unique<LineInfo>(aLineInfo));
rMtf.AddAction( new MetaPushAction( PushFlags::ALL ) );
// #106172# Track font relevant data in shadow VDev
@@ -1174,20 +1175,18 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf )
case GDI_POP_ACTION:
{
- LineInfo* pLineInfo;
- if (aLIStack.empty())
- pLineInfo = nullptr;
- else
+ std::unique_ptr<LineInfo> xLineInfo;
+ if (!aLIStack.empty())
{
- pLineInfo = aLIStack.top();
+ xLineInfo = std::move(aLIStack.top());
aLIStack.pop();
}
// restore line info
- if( pLineInfo )
+ if (xLineInfo)
{
- aLineInfo = *pLineInfo;
- delete pLineInfo;
+ aLineInfo = *xLineInfo;
+ xLineInfo.reset();
bFatLine = ( LineStyle::NONE != aLineInfo.GetStyle() ) && !aLineInfo.IsDefault();
}
@@ -1389,13 +1388,6 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf )
}
}
- // cleanup push-pop stack if necessary
- while( !aLIStack.empty() )
- {
- delete aLIStack.top();
- aLIStack.pop();
- }
-
rIStm.SetEndian( nOldFormat );
}