https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0461de33c5de3fee70a004b2f9c9e03ca70cfc67
commit 0461de33c5de3fee70a004b2f9c9e03ca70cfc67 Author: Kyle Katarn <cont...@kcsoftwares.com> AuthorDate: Tue May 5 10:44:45 2020 +0200 Commit: GitHub <nore...@github.com> CommitDate: Tue May 5 11:44:45 2020 +0300 [REGEDIT] Fix HeapFree() on the wrong variable (#2736) - When exporting registry keys (to .reg files) some variables from the heap are not free'd while the debug log indicates "HEAP: Trying to free an invalid address". - This is due to the export_registry_key() function that calls HeapFree() for reg_key_name. But this variable is an argument provided by the caller, which is always a statically defined array of WCHAR. - Meanwhile reg_key_name_buf is never free'd and cause a memory leak each time the function gets called. --- base/applications/regedit/regproc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/applications/regedit/regproc.c b/base/applications/regedit/regproc.c index c17221df5ae..41ac7c6be8b 100644 --- a/base/applications/regedit/regproc.c +++ b/base/applications/regedit/regproc.c @@ -1392,7 +1392,7 @@ BOOL export_registry_key(WCHAR *file_name, WCHAR *reg_key_name, DWORD format) if (file) { fclose(file); } - HeapFree(GetProcessHeap(), 0, reg_key_name); + HeapFree(GetProcessHeap(), 0, reg_key_name_buf); HeapFree(GetProcessHeap(), 0, val_name_buf); HeapFree(GetProcessHeap(), 0, val_buf); HeapFree(GetProcessHeap(), 0, line_buf);