https://git.reactos.org/?p=reactos.git;a=commitdiff;h=dae6035b3b3a0e21a61ea…
commit dae6035b3b3a0e21a61ea4cac32d5bc46c2abe66
Author: Jesús Sanz del Rey <jesussanz2003(a)gmail.com>
AuthorDate: Tue Jan 11 00:20:23 2022 +0100
Commit: GitHub <noreply(a)github.com>
CommitDate: Tue Jan 11 00:20:23 2022 +0100
[SHELL32] Fix recycle bin handle reference leaking (#4222)
CORE-13730
There was a handle reference leak in the recycler bin and the bin wasn't removing
the copied file after restoring it.
Close the handle were the memory leak was and move the file when restoring it.
---
dll/win32/shell32/folders/CRecycleBin.cpp | 21 ++++++++++-----------
dll/win32/shell32/shellrecyclebin/recyclebin_v5.c | 4 ++--
2 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/dll/win32/shell32/folders/CRecycleBin.cpp
b/dll/win32/shell32/folders/CRecycleBin.cpp
index dbf03672cee..cba7c52e42e 100644
--- a/dll/win32/shell32/folders/CRecycleBin.cpp
+++ b/dll/win32/shell32/folders/CRecycleBin.cpp
@@ -380,19 +380,18 @@ HRESULT WINAPI
CRecycleBinItemContextMenu::InvokeCommand(LPCMINVOKECOMMANDINFO l
if (!Context.bFound)
return E_FAIL;
- if (lpcmi->lpVerb == MAKEINTRESOURCEA(1))
- {
- /* restore file */
- if (RestoreFile(Context.hDeletedFile))
- return S_OK;
- else
- return E_FAIL;
- }
+ BOOL ret = TRUE;
+
+ /* restore file */
+ if (lpcmi->lpVerb == MAKEINTRESOURCEA(1))
+ ret = RestoreFile(Context.hDeletedFile);
+ /* delete file */
else
- {
DeleteFileHandleToRecycleBin(Context.hDeletedFile);
- return E_NOTIMPL;
- }
+
+ CloseRecycleBinHandle(Context.hDeletedFile);
+
+ return (ret ? S_OK : E_FAIL);
}
else if (lpcmi->lpVerb == MAKEINTRESOURCEA(3))
{
diff --git a/dll/win32/shell32/shellrecyclebin/recyclebin_v5.c
b/dll/win32/shell32/shellrecyclebin/recyclebin_v5.c
index 766bf4f4631..5bbd9548997 100644
--- a/dll/win32/shell32/shellrecyclebin/recyclebin_v5.c
+++ b/dll/win32/shell32/shellrecyclebin/recyclebin_v5.c
@@ -3,7 +3,7 @@
* LICENSE: GPL v2 - See COPYING in the top level directory
* FILE: lib/recyclebin/recyclebin_v5.c
* PURPOSE: Deals with recycle bins of Windows 2000/XP/2003
- * PROGRAMMERS: Copyright 2006-2007 Herv� Poussineau (hpoussin(a)reactos.org)
+ * PROGRAMMERS: Copyright 2006-2007 Hervé Poussineau (hpoussin(a)reactos.org)
*/
#include "recyclebin_private.h"
@@ -500,7 +500,7 @@ RecycleBin5_RecycleBin5_Restore(
{
/* Restore file */
ZeroMemory(&op, sizeof(op));
- op.wFunc = FO_COPY;
+ op.wFunc = FO_MOVE;
op.pFrom = pDeletedFileName;
op.pTo = pDeletedFile->FileNameW;