Author: hbelusca Date: Sun May 7 17:50:18 2017 New Revision: 74491
URL: http://svn.reactos.org/svn/reactos?rev=74491&view=rev Log: [NTOS]: Fix a potential memory leak. - If one of the ZwSetValueKey function fails, 'Node->ServiceName.Buffer' is leaked. - Also use 'L' prefix for wide characters. Patch by Lesan Ilie, thanks! - Use "P(C)WSTR" instead of win32 "LP(C)WSTR" string pointer types (by me). CORE-13207 #resolve
Modified: trunk/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c
Modified: trunk/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c... ============================================================================== --- trunk/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c [iso-8859-1] Sun May 7 17:50:18 2017 @@ -1144,6 +1144,7 @@
if (!NT_SUCCESS(Status)) { + ExFreePool(Node->ServiceName.Buffer); ExFreePoolWithTag(Node, TAG_IO_DEVNODE); return Status; } @@ -1437,7 +1438,7 @@ HANDLE hParent = NULL, hKey; OBJECT_ATTRIBUTES ObjectAttributes; UNICODE_STRING KeyName; - LPCWSTR Current, Last; + PCWSTR Current, Last; USHORT Length; NTSTATUS Status;
@@ -1462,7 +1463,7 @@ /* Go up to the end of the string */ while (Current <= Last) { - if (Current != Last && *Current != '\') + if (Current != Last && *Current != L'\') { /* Not the end of the string and not a separator */ Current++; @@ -1510,7 +1511,7 @@ /* Start with this new parent key */ hParent = hKey; Current++; - KeyName.Buffer = (LPWSTR)Current; + KeyName.Buffer = (PWSTR)Current; }
return STATUS_UNSUCCESSFUL; @@ -4258,7 +4259,7 @@ static WCHAR EnumKeyName[] = L"Enum\"; static WCHAR DeviceParametersKeyName[] = L"Device Parameters"; ULONG KeyNameLength; - LPWSTR KeyNameBuffer; + PWSTR KeyNameBuffer; UNICODE_STRING KeyName; ULONG DriverKeyLength; OBJECT_ATTRIBUTES ObjectAttributes;