From 80d1b13b182d535c25e01949c88ede891c82269a Mon Sep 17 00:00:00 2001 From: Jose Carlos Jesus Date: Sun, 7 May 2023 20:43:51 -0400 Subject: [PATCH 2/3] [REGEDIT] Simplifies and fix code style in GetItemPath function --- base/applications/regedit/treeview.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/base/applications/regedit/treeview.c b/base/applications/regedit/treeview.c index 12b9945d223..f6e37b7cbec 100644 --- a/base/applications/regedit/treeview.c +++ b/base/applications/regedit/treeview.c @@ -90,14 +90,25 @@ LPCWSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY* phRootKey) int pathLen = 0, maxLen; *phRootKey = NULL; - if (!pathBuffer) pathBuffer = HeapAlloc(GetProcessHeap(), 0, 1024); - if (!pathBuffer) return NULL; - *pathBuffer = 0; + + if (!pathBuffer) + { + pathBuffer = HeapAlloc(GetProcessHeap(), 0, 1024); + } + if (!pathBuffer) + { + return NULL; + } + + *pathBuffer = UNICODE_NULL; + maxLen = (int) HeapSize(GetProcessHeap(), 0, pathBuffer); - if (maxLen == -1) return NULL; - if (!hItem) hItem = TreeView_GetSelection(hwndTV); - if (!hItem) return NULL; - if (!get_item_path(hwndTV, hItem, phRootKey, &pathBuffer, &pathLen, &maxLen)) + + if (!hItem) + { + hItem = TreeView_GetSelection(hwndTV); + } + if (maxLen == -1 || !hItem || !get_item_path(hwndTV, hItem, phRootKey, &pathBuffer, &pathLen, &maxLen)) { return NULL; } -- 2.36.1.windows.1