diff options
author | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-04-26 11:42:35 +0100 |
---|---|---|
committer | Aron Budea <aron.budea@collabora.com> | 2024-05-06 23:28:41 +0200 |
commit | 615fd76c6ebea4efd228c5d3951b454ae56c1273 (patch) | |
tree | 97bb83ac64a499cc2e17dfc235400a9761d91268 /sfx2 | |
parent | 03d7f2365f0fba25496d787d1bd2de0d58634892 (diff) |
Unchecked HeapAlloc
Change-Id: Icd49d0b5f996d57d8e9518cb08fd3c3fc54fa779
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166732
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
(cherry picked from commit a70a8f55973ec3e71f65335be75699f1d2a73d62)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166833
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
(cherry picked from commit 1ddc294779d81ce2a00b75d283f183890074e650)
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/appl/shutdowniconw32.cxx | 15 | ||||
-rw-r--r-- | sfx2/source/doc/syspathw32.cxx | 21 |
2 files changed, 19 insertions, 17 deletions
diff --git a/sfx2/source/appl/shutdowniconw32.cxx b/sfx2/source/appl/shutdowniconw32.cxx index 2fb7cd2b7875..a237aac13547 100644 --- a/sfx2/source/appl/shutdowniconw32.cxx +++ b/sfx2/source/appl/shutdowniconw32.cxx @@ -681,15 +681,16 @@ static OUString SHGetSpecialFolder( int nFolderID ) if( hHdl == NOERROR ) { - WCHAR *lpFolderA; - lpFolderA = ALLOC( WCHAR, 16000 ); - - SHGetPathFromIDListW( pidl, lpFolderA ); - aFolder = o3tl::toU( lpFolderA ); + if (WCHAR *lpFolderA = ALLOC(WCHAR, 16000)) + { + SHGetPathFromIDListW(pidl, lpFolderA); + aFolder = o3tl::toU(lpFolderA); - FREE( lpFolderA ); - SHFree_( pidl ); + FREE(lpFolderA); + SHFree_(pidl); + } } + return aFolder; } diff --git a/sfx2/source/doc/syspathw32.cxx b/sfx2/source/doc/syspathw32.cxx index f60f459829d7..dce19e3625c0 100644 --- a/sfx2/source/doc/syspathw32.cxx +++ b/sfx2/source/doc/syspathw32.cxx @@ -37,17 +37,18 @@ static bool SHGetSpecialFolderW32( int nFolderID, WCHAR* pszFolder, int nSize ) if( hHdl == NOERROR ) { - WCHAR *lpFolder = static_cast< WCHAR* >( HeapAlloc( GetProcessHeap(), 0, 16000 )); - - SHGetPathFromIDListW( pidl, lpFolder ); - wcsncpy( pszFolder, lpFolder, nSize ); - - HeapFree( GetProcessHeap(), 0, lpFolder ); - IMalloc *pMalloc; - if( NOERROR == SHGetMalloc(&pMalloc) ) + if (WCHAR *lpFolder = static_cast<WCHAR*>(HeapAlloc(GetProcessHeap(), 0, 16000))) { - pMalloc->Free( pidl ); - pMalloc->Release(); + SHGetPathFromIDListW( pidl, lpFolder ); + wcsncpy( pszFolder, lpFolder, nSize ); + + HeapFree( GetProcessHeap(), 0, lpFolder ); + IMalloc *pMalloc; + if( NOERROR == SHGetMalloc(&pMalloc) ) + { + pMalloc->Free( pidl ); + pMalloc->Release(); + } } } return true; |