Commit in reactos/lib/user32/misc on MAIN
display.c+26-101.9 -> 1.10
Fixed handling of NULL arguments in ChangeDisplaySettings(Ex)(). Patch by blight.

reactos/lib/user32/misc
display.c 1.9 -> 1.10
diff -u -r1.9 -r1.10
--- display.c	9 Apr 2004 20:03:14 -0000	1.9
+++ display.c	8 Jul 2004 00:46:22 -0000	1.10
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: display.c,v 1.9 2004/04/09 20:03:14 navaraf Exp $
+/* $Id: display.c,v 1.10 2004/07/08 00:46:22 weiden Exp $
  *
  * PROJECT:         ReactOS user32.dll
  * FILE:            lib/user32/misc/dde.c
@@ -241,19 +241,30 @@
 {
   LONG rc;
   UNICODE_STRING DeviceName;
+  PUNICODE_STRING pDeviceName = &DeviceName;
   DEVMODEW DevModeW;
+  LPDEVMODEW pDevModeW = &DevModeW;
 
-  if ( !RtlCreateUnicodeStringFromAsciiz ( &DeviceName, (PCSZ)lpszDeviceName ) )
+  if (lpszDeviceName != NULL)
     {
-      SetLastError ( ERROR_OUTOFMEMORY );
-      return DISP_CHANGE_BADPARAM; /* FIXME what to return? */
+      if ( !RtlCreateUnicodeStringFromAsciiz ( pDeviceName, (PCSZ)lpszDeviceName ) )
+        {
+          SetLastError ( ERROR_OUTOFMEMORY );
+          return DISP_CHANGE_BADPARAM; /* FIXME what to return? */
+        }
     }
+  else
+    pDeviceName = NULL;
 
-  RosRtlDevModeA2W ( &DevModeW, lpDevMode );
+  if (lpDevMode != NULL)
+    RosRtlDevModeA2W ( pDevModeW, lpDevMode );
+  else
+    pDevModeW = NULL;
 
-  rc = NtUserChangeDisplaySettings ( &DeviceName, &DevModeW, hwnd, dwflags, lParam );
+  rc = NtUserChangeDisplaySettings ( pDeviceName, pDevModeW, hwnd, dwflags, lParam );
 
-  RtlFreeUnicodeString ( &DeviceName );
+  if (lpszDeviceName != NULL)
+    RtlFreeUnicodeString ( &DeviceName );
 
   return rc;
 }
@@ -286,12 +297,17 @@
 {
   LONG rc;
   UNICODE_STRING DeviceName;
+  PUNICODE_STRING pDeviceName = &DeviceName;
 
-  RtlInitUnicodeString ( &DeviceName, lpszDeviceName );
+  if (lpszDeviceName != NULL)
+    RtlInitUnicodeString ( pDeviceName, lpszDeviceName );
+  else
+    pDeviceName = NULL;
 
-  rc = NtUserChangeDisplaySettings ( &DeviceName, lpDevMode, hwnd, dwflags, lParam );
+  rc = NtUserChangeDisplaySettings ( pDeviceName, lpDevMode, hwnd, dwflags, lParam );
 
-  RtlFreeUnicodeString ( &DeviceName );
+  if (lpszDeviceName != NULL)
+    RtlFreeUnicodeString ( pDeviceName );
 
   return rc;
 }
CVSspam 0.2.8