diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-01-31 14:46:38 +0200 |
---|---|---|
committer | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2017-12-05 08:17:11 -0500 |
commit | 9ca19666511b1d44ba554a70cbbc0c8e2db844c6 (patch) | |
tree | 39a0bd694d2f1cf5d5a67082b85717e5bb2cbef0 /tools | |
parent | 6346e8c08e789e6aa4f2041fab97ba14419dedd4 (diff) |
loplugin:useuniqueptr extend to check local vars
just the simple and obvious case for now, of a local var being allocated
and deleted inside a single local block, and the delete happening at the
end of the block
Reviewed-on: https://gerrit.libreoffice.org/33749
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
(cherry picked from commit 2489000d3fd66319a8355fd4e37cfdfda47296d0)
Change-Id: I3a7a094da543debdcd2374737c2ecff91d644625
(cherry picked from commit e540ccfb5eb43bd4a3d6920074dce8436720ba8e)
Diffstat (limited to 'tools')
-rw-r--r-- | tools/source/generic/poly.cxx | 3 | ||||
-rw-r--r-- | tools/source/inet/inetmime.cxx | 7 |
2 files changed, 4 insertions, 6 deletions
diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx index 6a1a5a22387c..69e698b6d07a 100644 --- a/tools/source/generic/poly.cxx +++ b/tools/source/generic/poly.cxx @@ -600,7 +600,7 @@ Polygon::Polygon( const Rectangle& rRect, sal_uInt32 nHorzRound, sal_uInt32 nVer const Point aTR( aRect.Right() - nHorzRound, aRect.Top() + nVertRound ); const Point aBR( aRect.Right() - nHorzRound, aRect.Bottom() - nVertRound ); const Point aBL( aRect.Left() + nHorzRound, aRect.Bottom() - nVertRound ); - tools::Polygon* pEllipsePoly = new tools::Polygon( Point(), nHorzRound, nVertRound ); + std::unique_ptr<tools::Polygon> pEllipsePoly( new tools::Polygon( Point(), nHorzRound, nVertRound ) ); sal_uInt16 i, nEnd, nSize4 = pEllipsePoly->GetSize() >> 2; mpImplPolygon = new ImplPolygon( pEllipsePoly->GetSize() + 1 ); @@ -621,7 +621,6 @@ Polygon::Polygon( const Rectangle& rRect, sal_uInt32 nHorzRound, sal_uInt32 nVer ( pDstAry[ i ] = pSrcAry[ i ] ) += aBR; pDstAry[ nEnd ] = pDstAry[ 0 ]; - delete pEllipsePoly; } } } diff --git a/tools/source/inet/inetmime.cxx b/tools/source/inet/inetmime.cxx index 34fb6aa5df46..873f9e9f2b0f 100644 --- a/tools/source/inet/inetmime.cxx +++ b/tools/source/inet/inetmime.cxx @@ -2742,16 +2742,15 @@ void INetMIMEOutputSink::writeSequence(const sal_Unicode * pBegin, assert(pBegin && pBegin <= pEnd && "INetMIMEOutputSink::writeSequence(): Bad sequence"); - sal_Char * pBufferBegin = new sal_Char[pEnd - pBegin]; - sal_Char * pBufferEnd = pBufferBegin; + std::unique_ptr<sal_Char[]> pBufferBegin( new sal_Char[pEnd - pBegin] ); + sal_Char * pBufferEnd = pBufferBegin.get(); while (pBegin != pEnd) { DBG_ASSERT(*pBegin < 256, "INetMIMEOutputSink::writeSequence(): Bad octet"); *pBufferEnd++ = sal_Char(*pBegin++); } - writeSequence(pBufferBegin, pBufferEnd); - delete[] pBufferBegin; + writeSequence(pBufferBegin.get(), pBufferEnd); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |