setupapi: Fix some memory leaks in SetupDiGetINFClassA.

Spotted with Valgrind.
This commit is contained in:
Andrew Nguyen 2011-01-15 02:28:37 -06:00 committed by Alexandre Julliard
parent a91fd8fbb2
commit c66d27c555
1 changed files with 21 additions and 3 deletions

View File

@ -3998,10 +3998,26 @@ BOOL WINAPI SetupDiGetINFClassA(PCSTR inf, LPGUID class_guid, PSTR class_name,
PWSTR class_nameW = NULL;
UNICODE_STRING infW;
if (inf) RtlCreateUnicodeStringFromAsciiz(&infW, inf);
else infW.Buffer = NULL;
if (inf)
{
if (!RtlCreateUnicodeStringFromAsciiz(&infW, inf))
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
}
}
else
infW.Buffer = NULL;
if (class_name && size)
class_nameW = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR));
{
if (!(class_nameW = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR))))
{
RtlFreeUnicodeString(&infW);
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
}
}
retval = SetupDiGetINFClassW(infW.Buffer, class_guid, class_nameW, size, &required_sizeW);
@ -4015,6 +4031,8 @@ BOOL WINAPI SetupDiGetINFClassA(PCSTR inf, LPGUID class_guid, PSTR class_name,
else
if(required_size) *required_size = required_sizeW;
HeapFree(GetProcessHeap(), 0, class_nameW);
RtlFreeUnicodeString(&infW);
return retval;
}