Author: khornicek Date: Tue Oct 21 16:05:54 2014 New Revision: 64871
URL: http://svn.reactos.org/svn/reactos?rev=64871&view=rev Log: [CMD] - fix resource leaks CID 716324, 716323, 716322, 716321, 716320, 716319, 716318
Modified: trunk/reactos/base/shell/cmd/copy.c trunk/reactos/base/shell/cmd/internal.c trunk/reactos/base/shell/cmd/move.c trunk/reactos/base/shell/cmd/replace.c
Modified: trunk/reactos/base/shell/cmd/copy.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/copy.c?rev=6... ============================================================================== --- trunk/reactos/base/shell/cmd/copy.c [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/copy.c [iso-8859-1] Tue Oct 21 16:05:54 2014 @@ -136,6 +136,7 @@ _tcscat(TempSrc,_T(".decrypt")); if (!CopyFileEx(source, TempSrc, NULL, NULL, FALSE, COPY_FILE_ALLOW_DECRYPTED_DESTINATION)) { + CloseHandle (hFileSrc); nErrorLevel = 1; return 0; } @@ -766,6 +767,7 @@ /* Check Breaker */ if (CheckCtrlBreak(BREAK_INPUT)) { + FindClose(hFile); freep(arg); return 1; } @@ -789,6 +791,7 @@ if (_tcscmp(tmpDestPath, _T("\\.\")) && !IsExistingDirectory(tmpDestPath)) { + FindClose(hFile); ConOutFormatMessage(GetLastError(), szSrcPath); freep(arg); nErrorLevel = 1;
Modified: trunk/reactos/base/shell/cmd/internal.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/internal.c?r... ============================================================================== --- trunk/reactos/base/shell/cmd/internal.c [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/internal.c [iso-8859-1] Tue Oct 21 16:05:54 2014 @@ -382,7 +382,10 @@ { SetFileAttributes(TempFileName,FILE_ATTRIBUTE_NORMAL); if (!DeleteFile(TempFileName)) + { + FindClose (hFile); return 0; + } }
}while (FindNextFile (hFile, &f));
Modified: trunk/reactos/base/shell/cmd/move.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/move.c?rev=6... ============================================================================== --- trunk/reactos/base/shell/cmd/move.c [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/move.c [iso-8859-1] Tue Oct 21 16:05:54 2014 @@ -100,7 +100,7 @@ HANDLE hFile;
/* used only when source and destination directories are on different volume */ - HANDLE hDestFile; + HANDLE hDestFile = NULL; WIN32_FIND_DATA findDestBuffer; TCHAR szMoveDest[MAX_PATH]; TCHAR szMoveSrc[MAX_PATH]; @@ -505,6 +505,9 @@ FindNextFile (hFile, &findBuffer)); FindClose (hFile);
+ if(hDestFile && hDestFile != INVALID_HANDLE_VALUE) + FindClose(hDestFile); + freep (arg); return 0; }
Modified: trunk/reactos/base/shell/cmd/replace.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/replace.c?re... ============================================================================== --- trunk/reactos/base/shell/cmd/replace.c [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/replace.c [iso-8859-1] Tue Oct 21 16:05:54 2014 @@ -131,7 +131,10 @@ else ConOutResPrintf(STRING_REPLACE_HELP10, dest); if ( !FilePromptYNA (0)) + { + CloseHandle (hFileSrc); return 0; + } }
/* Output depending on add flag */ @@ -220,7 +223,7 @@ HANDLE hFile; WIN32_FIND_DATA findBuffer;
- /* Get file handel to the sourcefile(s) */ + /* Get file handle to the sourcefile(s) */ hFile = FindFirstFile (szSrcPath, &findBuffer);
/* @@ -301,6 +304,8 @@
/* Take next sourcefile if any */ } while(FindNextFile (hFile, &findBuffer)); + + FindClose(hFile);
return filesReplaced; } @@ -377,6 +382,8 @@ } /* Get the next handle */ } while(FindNextFile (hFile, &findBuffer)); + + FindClose(hFile);
return filesReplaced; }