Author: gedmurphy
Date: Sat May 27 19:06:51 2006
New Revision: 22078
URL:
http://svn.reactos.ru/svn/reactos?rev=22078&view=rev
Log:
Fix possible memory leak in ProbeAndCaptureUnicodeString
Patch from Thomas Weidenmueller
Modified:
trunk/reactos/include/reactos/probe.h
Modified: trunk/reactos/include/reactos/probe.h
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/include/reactos/probe.h?rev…
==============================================================================
--- trunk/reactos/include/reactos/probe.h (original)
+++ trunk/reactos/include/reactos/probe.h Sat May 27 19:06:51 2006
@@ -31,7 +31,7 @@
#define ProbeForWriteBoolean(Ptr) ProbeForWriteGenericType(Ptr, BOOLEAN)
#define ProbeForWriteUchar(Ptr) ProbeForWriteGenericType(Ptr, UCHAR)
-#define ProbeForWriteChar(Ptr) ProbeForWriteGenericType(Ptr, Char)
+#define ProbeForWriteChar(Ptr) ProbeForWriteGenericType(Ptr, CHAR)
#define ProbeForWriteUshort(Ptr) ProbeForWriteGenericType(Ptr, USHORT)
#define ProbeForWriteShort(Ptr) ProbeForWriteGenericType(Ptr, SHORT)
#define ProbeForWriteUlong(Ptr) ProbeForWriteGenericType(Ptr, ULONG)
@@ -85,7 +85,7 @@
IN PUNICODE_STRING UnsafeSrc)
{
NTSTATUS Status = STATUS_SUCCESS;
- WCHAR *Buffer;
+ WCHAR *Buffer = NULL;
ASSERT(Dest != NULL);
/* Probe the structure and buffer*/
@@ -136,6 +136,16 @@
}
_SEH_HANDLE
{
+ /* Free allocated resources and zero the destination string */
+ if (Buffer != NULL)
+ {
+ ExFreePool(Buffer);
+ }
+ Dest->Length = 0;
+ Dest->MaximumLength = 0;
+ Dest->Buffer = NULL;
+
+ /* Return the error code */
Status = _SEH_GetExceptionCode();
}
_SEH_END;