parentPath is allocated before parentKey.
From: Alex Henrie alexhenrie24@gmail.com
parentPath is allocated before parentKey. --- programs/regedit/edit.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/programs/regedit/edit.c b/programs/regedit/edit.c index 66d3a27dc68..947a6071e0f 100644 --- a/programs/regedit/edit.c +++ b/programs/regedit/edit.c @@ -680,9 +680,7 @@ BOOL RenameKey(HWND hwnd, HKEY hRootKey, LPCWSTR keyPath, LPCWSTR newName)
done: RegCloseKey(destKey); - if (parentKey) { - RegCloseKey(parentKey); - free(parentPath); - } + RegCloseKey(parentKey); + free(parentPath); return result; }
We could probably use RegRenameKey() instead of this helper.
On Sun Jun 25 04:51:30 2023 +0000, Nikolay Sivov wrote:
We could probably use RegRenameKey() instead of this helper.
Parts of this function could be reimplemented on top of RegRenameKey, but if we're going to continue having a distinct error message if the destination key already exists (and we probably should because Windows does), it's still necessary to extract the parent path in order to check. So the memory leak would still have to be addressed.