fix memmory coruption in EnumDisplaySettingsExA

do not alloc memmory with heap. 

svn path=/trunk/; revision=15542
This commit is contained in:
Magnus Olsen 2005-05-27 14:22:06 +00:00
parent 68f4fc41bc
commit b73c53c40c

View file

@ -200,15 +200,7 @@ EnumDisplaySettingsExA(
{ {
BOOL rc; BOOL rc;
UNICODE_STRING DeviceName; UNICODE_STRING DeviceName;
LPDEVMODEW lpDevModeW; DEVMODEW lpDevModeW;
lpDevModeW = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(DEVMODEW) + lpDevMode->dmDriverExtra);
if ( lpDevModeW == NULL )
{
SetLastError ( ERROR_OUTOFMEMORY );
return FALSE;
}
if ( !RtlCreateUnicodeStringFromAsciiz ( &DeviceName, (PCSZ)lpszDeviceName ) ) if ( !RtlCreateUnicodeStringFromAsciiz ( &DeviceName, (PCSZ)lpszDeviceName ) )
{ {
@ -216,16 +208,16 @@ EnumDisplaySettingsExA(
return FALSE; return FALSE;
} }
lpDevModeW->dmSize = sizeof(DEVMODEW); memset(&lpDevModeW,0,sizeof(DEVMODEW));
lpDevModeW->dmDriverExtra = 0; lpDevModeW.dmSize = sizeof(DEVMODEW);
rc = NtUserEnumDisplaySettings ( &DeviceName, iModeNum, lpDevModeW, rc = NtUserEnumDisplaySettings ( &DeviceName, iModeNum, &lpDevModeW,
dwFlags ); dwFlags );
RosRtlDevModeW2A ( lpDevMode, lpDevModeW ); RosRtlDevModeW2A ( lpDevMode, &lpDevModeW );
RtlFreeUnicodeString ( &DeviceName ); RtlFreeUnicodeString ( &DeviceName );
HeapFree ( GetProcessHeap(), 0, lpDevModeW );
return rc; return rc;
} }