fix memmory coruption in EnumDisplaySettingsExA
do not alloc memmory with heap.
Modified: trunk/reactos/lib/user32/misc/display.c
_____
Modified: trunk/reactos/lib/user32/misc/display.c
--- trunk/reactos/lib/user32/misc/display.c 2005-05-27 00:32:24 UTC
(rev 15541)
+++ trunk/reactos/lib/user32/misc/display.c 2005-05-27 14:22:06 UTC
(rev 15542)
@@ -200,33 +200,25 @@
{
BOOL rc;
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 ) )
{
SetLastError ( ERROR_OUTOFMEMORY );
return FALSE;
}
- lpDevModeW->dmSize = sizeof(DEVMODEW);
- lpDevModeW->dmDriverExtra = 0;
-
- rc = NtUserEnumDisplaySettings ( &DeviceName, iModeNum, lpDevModeW,
+ memset(&lpDevModeW,0,sizeof(DEVMODEW));
+ lpDevModeW.dmSize = sizeof(DEVMODEW);
+
+ rc = NtUserEnumDisplaySettings ( &DeviceName, iModeNum, &lpDevModeW,
dwFlags );
- RosRtlDevModeW2A ( lpDevMode, lpDevModeW );
+ RosRtlDevModeW2A ( lpDevMode, &lpDevModeW );
RtlFreeUnicodeString ( &DeviceName );
- HeapFree ( GetProcessHeap(), 0, lpDevModeW );
+
return rc;
}
Show replies by date