From c0d7a40be2444df158c34fb8aca6a9ff28d9138a Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Wed, 8 Feb 2017 08:41:00 +0100 Subject: loplugin:useuniqueptr (clang-cl) Change-Id: Ic774c9ad174ea522da85585cd1d36f89ca6b1d64 --- fpicker/source/win32/filepicker/getfilenamewrapper.cxx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'fpicker') diff --git a/fpicker/source/win32/filepicker/getfilenamewrapper.cxx b/fpicker/source/win32/filepicker/getfilenamewrapper.cxx index 16b648da24c4..a7a5a3d764e6 100644 --- a/fpicker/source/win32/filepicker/getfilenamewrapper.cxx +++ b/fpicker/source/win32/filepicker/getfilenamewrapper.cxx @@ -17,6 +17,9 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include + +#include #include #include #include @@ -70,19 +73,17 @@ namespace /* private */ if ( m_nBufLen - 1 > MAX_PATH ) { DWORD nNewLen = m_nBufLen + 8; - wchar_t* pNewBuffer = new wchar_t[nNewLen]; + auto pNewBuffer = std::unique_ptr(new wchar_t[nNewLen]); if ( m_nBufLen > 3 && m_pBuffer[0] == (wchar_t)'\\' && m_pBuffer[1] == (wchar_t)'\\' ) { if ( m_pBuffer[2] == (wchar_t)'?' ) - _snwprintf( pNewBuffer, nNewLen, L"%s", m_pBuffer ); + _snwprintf( pNewBuffer.get(), nNewLen, L"%s", m_pBuffer ); else - _snwprintf( pNewBuffer, nNewLen, L"\\\\?\\UNC\\%s", m_pBuffer+2 ); + _snwprintf( pNewBuffer.get(), nNewLen, L"\\\\?\\UNC\\%s", m_pBuffer+2 ); } else - _snwprintf( pNewBuffer, nNewLen, L"\\\\?\\%s", m_pBuffer ); - bDirSet = SetCurrentDirectoryW( pNewBuffer ); - - delete [] pNewBuffer; + _snwprintf( pNewBuffer.get(), nNewLen, L"\\\\?\\%s", m_pBuffer ); + bDirSet = SetCurrentDirectoryW( pNewBuffer.get() ); } else bDirSet = SetCurrentDirectoryW( m_pBuffer ); -- cgit