[CMD]
authorThomas Faber <thomas.faber@reactos.org>
Mon, 12 May 2014 06:19:07 +0000 (06:19 +0000)
committerThomas Faber <thomas.faber@reactos.org>
Mon, 12 May 2014 06:19:07 +0000 (06:19 +0000)
- Fix mismatched allocation/free. Spotted by Samuel & cppcheck
CORE-8207 #resolve

svn path=/trunk/; revision=63249

reactos/base/shell/cmd/copy.c
reactos/base/shell/cmd/replace.c

index a5f896d..c5c127f 100644 (file)
@@ -200,7 +200,7 @@ copy(TCHAR source[MAX_PATH],
     }
 
     /* A page-aligned buffer usually give more speed */
-    buffer = (LPBYTE)VirtualAlloc(NULL, BUFF_SIZE, MEM_COMMIT, PAGE_READWRITE);
+    buffer = VirtualAlloc(NULL, BUFF_SIZE, MEM_COMMIT, PAGE_READWRITE);
     if (buffer == NULL)
     {
         CloseHandle (hFileDest);
index 4b139c8..864e3fb 100644 (file)
@@ -160,7 +160,7 @@ INT replace(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], DWORD dwFlags, BOOL *d
     }
 
     /* Get buffer for the copy process */
-    buffer = (LPBYTE)VirtualAlloc(NULL, BUFF_SIZE, MEM_COMMIT, PAGE_READWRITE);
+    buffer = VirtualAlloc(NULL, BUFF_SIZE, MEM_COMMIT, PAGE_READWRITE);
     if (buffer == NULL)
     {
         CloseHandle (hFileDest);
@@ -188,7 +188,7 @@ INT replace(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], DWORD dwFlags, BOOL *d
         if (dwWritten != dwRead || CheckCtrlBreak(BREAK_INPUT))
         {
             ConOutResPuts(STRING_COPY_ERROR3);
-            cmd_free (buffer);
+            VirtualFree (buffer, 0, MEM_RELEASE);
             CloseHandle (hFileDest);
             CloseHandle (hFileSrc);
             nErrorLevel = 1;