[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.
This commit is contained in:
Jesús Sanz del Rey 2022-01-11 00:20:23 +01:00 committed by GitHub
parent 3456538e3a
commit dae6035b3b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 13 deletions

View file

@ -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))
{

View file

@ -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@reactos.org)
* PROGRAMMERS: Copyright 2006-2007 Hervé Poussineau (hpoussin@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;