fixed some memory leaks with GetClassInfoEx(A/W)

svn path=/trunk/; revision=5665
This commit is contained in:
Royce Mitchell III 2003-08-19 02:55:53 +00:00
parent b46260a736
commit b3b09803f9

View file

@ -1,4 +1,4 @@
/* $Id: class.c,v 1.33 2003/08/19 01:03:41 weiden Exp $
/* $Id: class.c,v 1.34 2003/08/19 02:55:53 royce Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS user32.dll
@ -41,20 +41,23 @@ GetClassInfoExA(
if(IS_ATOM(lpszClass))
str = (LPWSTR)lpszClass;
else
{
Status = HEAP_strdupAtoW (&str, lpszClass, NULL);
if ( !NT_SUCCESS (Status) )
{
SetLastError (RtlNtStatusToDosError(Status));
return FALSE;
}
}
str2.Length = 0;
str2.MaximumLength = 255;
str2.Buffer = (PWSTR)RtlAllocateHeap(RtlGetProcessHeap(), 0,
str2.MaximumLength * sizeof(WCHAR));
str2.Buffer = (PWSTR)HEAP_alloc ( str2.MaximumLength * sizeof(WCHAR) );
if ( !str2.Buffer )
{
SetLastError (RtlNtStatusToDosError(STATUS_NO_MEMORY));
if ( !IS_ATOM(str) )
HEAP_free ( str );
return FALSE;
}
@ -68,7 +71,8 @@ GetClassInfoExA(
{
lpwcx->lpszMenuName = heap_string_poolA ( str2.Buffer, str2.Length );
}
RtlFreeHeap(RtlGetProcessHeap(), 0, str2.Buffer);
HEAP_free ( str2.Buffer );
return retval;
}
@ -97,15 +101,23 @@ GetClassInfoExW(
if(IS_ATOM(lpszClass))
str = (LPWSTR)lpszClass;
else
{
str = HEAP_strdupW ( lpszClass, wcslen(lpszClass) );
if ( !str )
{
SetLastError (RtlNtStatusToDosError(STATUS_NO_MEMORY));
return FALSE;
}
}
str2.Length = 0;
str2.MaximumLength = 255;
str2.Buffer = (PWSTR)RtlAllocateHeap(RtlGetProcessHeap(), 0,
str2.MaximumLength * sizeof(WCHAR));
str2.Buffer = (PWSTR)HEAP_alloc ( str2.MaximumLength * sizeof(WCHAR) );
if ( !str2.Buffer )
{
SetLastError (RtlNtStatusToDosError(STATUS_NO_MEMORY));
if ( !IS_ATOM(str) )
HEAP_free ( str );
return FALSE;
}
@ -120,7 +132,8 @@ GetClassInfoExW(
lpwcx->lpszMenuName = heap_string_poolW ( str2.Buffer, str2.Length );
}
RtlFreeHeap(RtlGetProcessHeap(), 0, str2.Buffer);
HEAP_free ( str2.Buffer );
return retval;
}