CopyAcceleratorTableA: dont access lpAccelDst it its NULL (w3seek)
authorGunnar Dalsnes <hardon@online.no>
Mon, 21 Mar 2005 17:11:48 +0000 (17:11 +0000)
committerGunnar Dalsnes <hardon@online.no>
Mon, 21 Mar 2005 17:11:48 +0000 (17:11 +0000)
svn path=/trunk/; revision=14254

reactos/lib/user32/windows/accel.c

index 5840e2a..3949548 100644 (file)
@@ -285,38 +285,34 @@ HACCEL WINAPI CreateAcceleratorTableW(LPACCEL lpaccl, int cEntries)
 }
 
 
-/*
- * @implemented
- */
 int WINAPI CopyAcceleratorTableA
 (
  HACCEL hAccelSrc,
- LPACCEL lpAccelDst,
+ LPACCEL lpAccelDst, /* can be NULL */
  int cAccelEntries
 )
 {
- int i;
-
- cAccelEntries = CopyAcceleratorTableW(hAccelSrc, lpAccelDst, cAccelEntries);
+   int i;
  
- if(cAccelEntries == 0) return 0;
-
- for(i = 0; i < cAccelEntries; ++ i)
-  if(!(lpAccelDst[i].fVirt & FVIRTKEY))
-  {
-   NTSTATUS nErrCode = RtlUnicodeToMultiByteN
-   (
-    (PCHAR)&lpAccelDst[i].key,
-    sizeof(lpAccelDst[i].key),
-    NULL,
-    (PWCHAR)&lpAccelDst[i].key,
-    sizeof(lpAccelDst[i].key)
-   );
-
-   if(!NT_SUCCESS(nErrCode)) lpAccelDst[i].key = 0;
-  }
-
- return cAccelEntries;
+   cAccelEntries = CopyAcceleratorTableW(hAccelSrc, lpAccelDst, cAccelEntries);
+   if (lpAccelDst == NULL) return cAccelEntries;
+
+   for(i = 0; i < cAccelEntries; ++ i)
+   if(!(lpAccelDst[i].fVirt & FVIRTKEY))
+   {
+      NTSTATUS nErrCode = RtlUnicodeToMultiByteN(
+         (PCHAR)&lpAccelDst[i].key,
+         sizeof(lpAccelDst[i].key),
+         NULL,
+         (PWCHAR)&lpAccelDst[i].key,
+         sizeof(lpAccelDst[i].key)
+         ); 
+      if(!NT_SUCCESS(nErrCode)) lpAccelDst[i].key = 0;
+   }
+   return cAccelEntries;
 }