Author: gschneider
Date: Sat May 29 14:31:48 2010
New Revision: 47407
URL:
http://svn.reactos.org/svn/reactos?rev=47407&view=rev
Log:
[KERNEL32] ReplaceFileW:
- Initialize Unicode string structure, so that only allocated buffers are freed when
leaving the function
- Fixes several heap warnings in kernel32:file test
Modified:
trunk/reactos/dll/win32/kernel32/file/file.c
Modified: trunk/reactos/dll/win32/kernel32/file/file.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/file/fi…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/file/file.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/file/file.c [iso-8859-1] Sat May 29 14:31:48 2010
@@ -1906,7 +1906,8 @@
)
{
HANDLE hReplaced = NULL, hReplacement = NULL;
- UNICODE_STRING NtReplacedName, NtReplacementName;
+ UNICODE_STRING NtReplacedName = { 0, 0, NULL };
+ UNICODE_STRING NtReplacementName = { 0, 0, NULL };
DWORD Error = ERROR_SUCCESS;
NTSTATUS Status;
BOOL Ret = FALSE;
@@ -2029,8 +2030,10 @@
if (hReplacement) NtClose(hReplacement);
if (Buffer) RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
- RtlFreeUnicodeString(&NtReplacementName);
- RtlFreeUnicodeString(&NtReplacedName);
+ if (NtReplacementName.Buffer)
+ RtlFreeHeap(GetProcessHeap(), 0, NtReplacementName.Buffer);
+ if (NtReplacedName.Buffer)
+ RtlFreeHeap(GetProcessHeap(), 0, NtReplacedName.Buffer);
/* If there was an error, set the error code */
if(!Ret)