From aa09b0c27a6d925da428d6267daadc7338829869 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 6 Apr 2017 09:46:06 +0200 Subject: loplugin:useuniqueptr extend to catch more localvar cases i.e. where the code looks like { foo * p = new foo; ... delete p; return ...; } Change-Id: Id5f2e55d0363fc62c72535a23faeaaf1f0ac6aee Reviewed-on: https://gerrit.libreoffice.org/36190 Tested-by: Jenkins Reviewed-by: Noel Grandin --- hwpfilter/source/hwpfile.cxx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'hwpfilter/source/hwpfile.cxx') diff --git a/hwpfilter/source/hwpfile.cxx b/hwpfilter/source/hwpfile.cxx index 90fdfdbfe86c..3ab2b0087a6c 100644 --- a/hwpfilter/source/hwpfile.cxx +++ b/hwpfilter/source/hwpfile.cxx @@ -244,7 +244,7 @@ void HWPFile::ParaListRead() bool HWPFile::ReadParaList(std::list < HWPPara* > &aplist, unsigned char flag) { - HWPPara *spNode = new HWPPara; + std::unique_ptr spNode( new HWPPara ); unsigned char tmp_etcflag; unsigned char prev_etcflag = 0; while (spNode->Read(*this, flag)) @@ -269,11 +269,10 @@ bool HWPFile::ReadParaList(std::list < HWPPara* > &aplist, unsigned char flag) AddParaShape( &spNode->pshape ); if (!aplist.empty()) - aplist.back()->SetNext(spNode); - aplist.push_back(spNode); - spNode = new HWPPara; + aplist.back()->SetNext(spNode.get()); + aplist.push_back(spNode.release()); + spNode.reset( new HWPPara ); } - delete spNode; return true; } -- cgit v1.2.3