From 03a8c91d75885f47c18e9991ab5ceb74cb76b75c Mon Sep 17 00:00:00 2001 From: Rafal Harabien Date: Fri, 25 Mar 2011 22:57:46 +0000 Subject: [PATCH] [WIN32K] wcsncpy -> safe api (part 3/x) svn path=/trunk/; revision=51143 --- reactos/subsystems/win32/win32k/eng/device.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/reactos/subsystems/win32/win32k/eng/device.c b/reactos/subsystems/win32/win32k/eng/device.c index 3e6759499e0..802bcf50e4f 100644 --- a/reactos/subsystems/win32/win32k/eng/device.c +++ b/reactos/subsystems/win32/win32k/eng/device.c @@ -84,12 +84,13 @@ EngpRegisterGraphicsDevice( 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 @@ EngpRegisterGraphicsDevice( { DPRINT1("Could not allocate string buffer\n"); ASSERT(FALSE); // FIXME + ExFreePoolWithTag(pGraphicsDevice, GDITAG_GDEVICE); + return NULL; } /* Copy display driver names */ @@ -160,7 +163,7 @@ EngpRegisterGraphicsDevice( if (!pGraphicsDevice->pdevmodeInfo || cModes == 0) { DPRINT1("No devmodes\n"); - ExFreePool(pGraphicsDevice); + ExFreePoolWithTag(pGraphicsDevice, GDITAG_GDEVICE); return NULL; } @@ -172,7 +175,7 @@ EngpRegisterGraphicsDevice( if (!pGraphicsDevice->pDevModeList) { DPRINT1("No devmode list\n"); - ExFreePool(pGraphicsDevice); + ExFreePoolWithTag(pGraphicsDevice, GDITAG_GDEVICE); return NULL; } -- 2.17.1