mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-01 00:13:37 +00:00
regedit: Fix potential buffer leak, simplify error handling (Coverity).
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
0aa56cabe4
commit
c9fb3b7f8f
|
@ -95,17 +95,17 @@ static BOOL get_item_path(HWND hwndTV, HTREEITEM hItem, HKEY* phKey, LPWSTR* pKe
|
|||
|
||||
LPWSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY* phRootKey)
|
||||
{
|
||||
int pathLen = 0, maxLen;
|
||||
int pathLen = 0, maxLen = 1024;
|
||||
WCHAR *pathBuffer;
|
||||
|
||||
pathBuffer = HeapAlloc(GetProcessHeap(), 0, 1024*sizeof(WCHAR));
|
||||
if (!hItem) {
|
||||
hItem = (HTREEITEM)SendMessageW(hwndTV, TVM_GETNEXTITEM, TVGN_CARET, 0);
|
||||
if (!hItem) return NULL;
|
||||
}
|
||||
|
||||
pathBuffer = HeapAlloc(GetProcessHeap(), 0, maxLen*sizeof(WCHAR));
|
||||
if (!pathBuffer) return NULL;
|
||||
*pathBuffer = 0;
|
||||
maxLen = HeapSize(GetProcessHeap(), 0, pathBuffer);
|
||||
if (maxLen == (SIZE_T) - 1) return NULL;
|
||||
maxLen = maxLen / sizeof(WCHAR);
|
||||
if (!hItem) hItem = (HTREEITEM)SendMessageW(hwndTV, TVM_GETNEXTITEM, TVGN_CARET, 0);
|
||||
if (!hItem) return NULL;
|
||||
if (!get_item_path(hwndTV, hItem, phRootKey, &pathBuffer, &pathLen, &maxLen)) return NULL;
|
||||
return pathBuffer;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue