[ros-diffs] [rharabien] 51143: [WIN32K] wcsncpy -> safe api (part 3/x)

rharabien at svn.reactos.org rharabien at svn.reactos.org
Fri Mar 25 22:57:46 UTC 2011


Author: rharabien
Date: Fri Mar 25 22:57:46 2011
New Revision: 51143

URL: http://svn.reactos.org/svn/reactos?rev=51143&view=rev
Log:
[WIN32K]

wcsncpy -> safe api (part 3/x)

Modified:
    trunk/reactos/subsystems/win32/win32k/eng/device.c

Modified: trunk/reactos/subsystems/win32/win32k/eng/device.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/eng/device.c?rev=51143&r1=51142&r2=51143&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/eng/device.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/eng/device.c [iso-8859-1] Fri Mar 25 22:57:46 2011
@@ -84,12 +84,13 @@
     pGraphicsDevice->FileObject = pFileObject;
 
     /* Copy device name */
-    wcsncpy(pGraphicsDevice->szNtDeviceName,
-            pustrDeviceName->Buffer,
-            sizeof(pGraphicsDevice->szNtDeviceName) / sizeof(WCHAR));
+    RtlStringCbCopyNW(pGraphicsDevice->szNtDeviceName,
+                     sizeof(pGraphicsDevice->szNtDeviceName),
+                     pustrDeviceName->Buffer,
+                     pustrDeviceName->Length);
 
     /* Create a win device name (FIXME: virtual devices!) */
-    swprintf(pGraphicsDevice->szWinDeviceName, L"\\\\.\\VIDEO%d", (CHAR)giDevNum);
+    swprintf(pGraphicsDevice->szWinDeviceName, L"\\\\.\\VIDEO%d", (int)giDevNum);
 
     /* Allocate a buffer for the strings */
     cj = pustrDiplayDrivers->Length + pustrDescription->Length + sizeof(WCHAR);
@@ -98,6 +99,8 @@
     {
         DPRINT1("Could not allocate string buffer\n");
         ASSERT(FALSE); // FIXME
+        ExFreePoolWithTag(pGraphicsDevice, GDITAG_GDEVICE);
+        return NULL;
     }
 
     /* Copy display driver names */
@@ -160,7 +163,7 @@
     if (!pGraphicsDevice->pdevmodeInfo || cModes == 0)
     {
         DPRINT1("No devmodes\n");
-        ExFreePool(pGraphicsDevice);
+        ExFreePoolWithTag(pGraphicsDevice, GDITAG_GDEVICE);
         return NULL;
     }
 
@@ -172,7 +175,7 @@
     if (!pGraphicsDevice->pDevModeList)
     {
         DPRINT1("No devmode list\n");
-        ExFreePool(pGraphicsDevice);
+        ExFreePoolWithTag(pGraphicsDevice, GDITAG_GDEVICE);
         return NULL;
     }
 




More information about the Ros-diffs mailing list