[PATCH 0/1] MR3098: regedit: Fix memory leak on error path in RenameKey (scan-build).
parentPath is allocated before parentKey. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/3098
From: Alex Henrie <alexhenrie24(a)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; } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/3098
We could probably use RegRenameKey() instead of this helper. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/3098#note_36095
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.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/3098#note_36717
participants (3)
-
Alex Henrie -
Alex Henrie (@alexhenrie) -
Nikolay Sivov (@nsivov)