Fix GetUserNameA/GetComputerNameExA

Patch by Carlo Bramini, carlo dot bramix at libero dot it
See issue #1859 for more details.

svn path=/trunk/; revision=34159
This commit is contained in:
Hervé Poussineau 2008-06-28 16:51:42 +00:00
parent 0b91e99584
commit ec92a60952
2 changed files with 3 additions and 3 deletions

View file

@ -723,7 +723,6 @@ GetUserNameA( LPSTR lpszName, LPDWORD lpSize )
/* apparently Win doesn't check whether lpSize is valid at all! */
NameW.Length = 0;
NameW.MaximumLength = (*lpSize) * sizeof(WCHAR);
NameW.Buffer = LocalAlloc(LMEM_FIXED, NameW.MaximumLength);
if(NameW.Buffer == NULL)
@ -740,6 +739,7 @@ GetUserNameA( LPSTR lpszName, LPDWORD lpSize )
lpSize);
if(Ret)
{
NameW.Length = (*lpSize) * sizeof(WCHAR);
RtlUnicodeStringToAnsiString(&NameA, &NameW, FALSE);
NameA.Buffer[NameA.Length] = '\0';

View file

@ -232,7 +232,7 @@ GetComputerNameExA (
UNICODE_STRING UnicodeString;
ANSI_STRING AnsiString;
BOOL Result;
PWCHAR TempBuffer = RtlAllocateHeap( GetProcessHeap(), 0, *nSize * sizeof(WCHAR) );
PWCHAR TempBuffer = RtlAllocateHeap( RtlGetProcessHeap(), 0, *nSize * sizeof(WCHAR) );
if( !TempBuffer ) {
return ERROR_OUTOFMEMORY;
@ -254,7 +254,7 @@ GetComputerNameExA (
FALSE);
}
HeapFree( GetProcessHeap(), 0, TempBuffer );
RtlFreeHeap( RtlGetProcessHeap(), 0, TempBuffer );
return Result;
}