wcsncpy -> safe api (part 3/x)

svn path=/trunk/; revision=51143
This commit is contained in:
Rafal Harabien 2011-03-25 22:57:46 +00:00
parent 00cfa29229
commit 03a8c91d75

View file

@ -84,12 +84,13 @@ EngpRegisterGraphicsDevice(
pGraphicsDevice->FileObject = pFileObject; pGraphicsDevice->FileObject = pFileObject;
/* Copy device name */ /* Copy device name */
wcsncpy(pGraphicsDevice->szNtDeviceName, RtlStringCbCopyNW(pGraphicsDevice->szNtDeviceName,
pustrDeviceName->Buffer, sizeof(pGraphicsDevice->szNtDeviceName),
sizeof(pGraphicsDevice->szNtDeviceName) / sizeof(WCHAR)); pustrDeviceName->Buffer,
pustrDeviceName->Length);
/* Create a win device name (FIXME: virtual devices!) */ /* 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 */ /* Allocate a buffer for the strings */
cj = pustrDiplayDrivers->Length + pustrDescription->Length + sizeof(WCHAR); cj = pustrDiplayDrivers->Length + pustrDescription->Length + sizeof(WCHAR);
@ -98,6 +99,8 @@ EngpRegisterGraphicsDevice(
{ {
DPRINT1("Could not allocate string buffer\n"); DPRINT1("Could not allocate string buffer\n");
ASSERT(FALSE); // FIXME ASSERT(FALSE); // FIXME
ExFreePoolWithTag(pGraphicsDevice, GDITAG_GDEVICE);
return NULL;
} }
/* Copy display driver names */ /* Copy display driver names */
@ -160,7 +163,7 @@ EngpRegisterGraphicsDevice(
if (!pGraphicsDevice->pdevmodeInfo || cModes == 0) if (!pGraphicsDevice->pdevmodeInfo || cModes == 0)
{ {
DPRINT1("No devmodes\n"); DPRINT1("No devmodes\n");
ExFreePool(pGraphicsDevice); ExFreePoolWithTag(pGraphicsDevice, GDITAG_GDEVICE);
return NULL; return NULL;
} }
@ -172,7 +175,7 @@ EngpRegisterGraphicsDevice(
if (!pGraphicsDevice->pDevModeList) if (!pGraphicsDevice->pDevModeList)
{ {
DPRINT1("No devmode list\n"); DPRINT1("No devmode list\n");
ExFreePool(pGraphicsDevice); ExFreePoolWithTag(pGraphicsDevice, GDITAG_GDEVICE);
return NULL; return NULL;
} }