https://git.reactos.org/?p=reactos.git;a=commitdiff;h=838abc475cfc485acdc362e0df88b4590081c8e4

commit 838abc475cfc485acdc362e0df88b4590081c8e4
Author:     Jérôme Gardou <jerome.gar...@reactos.org>
AuthorDate: Thu Jun 17 17:47:01 2021 +0200
Commit:     Jérôme Gardou <zefk...@users.noreply.github.com>
CommitDate: Mon Jun 28 10:20:57 2021 +0200

    [NTOS:IO] Do not ignore RtlDuplicateUnicodeString return value
    
    CORE-17637
---
 ntoskrnl/io/pnpmgr/devaction.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/ntoskrnl/io/pnpmgr/devaction.c b/ntoskrnl/io/pnpmgr/devaction.c
index b98c2145723..18a435f3a38 100644
--- a/ntoskrnl/io/pnpmgr/devaction.c
+++ b/ntoskrnl/io/pnpmgr/devaction.c
@@ -1396,6 +1396,14 @@ IopSetServiceEnumData(
         goto done;
     }
 
+    Status = 
RtlDuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING,
+                                       &ServiceName,
+                                       &DeviceNode->ServiceName);
+    if (!NT_SUCCESS(Status))
+    {
+        goto done;
+    }
+
     RtlInitUnicodeString(&EnumKeyName, L"Enum");
     Status = IopCreateRegistryKeyEx(&ServiceEnumKey,
                                     ServiceKey,
@@ -1480,10 +1488,6 @@ IopSetServiceEnumData(
                                sizeof(NextInstance));
     }
 
-    
RtlDuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING,
-                              &ServiceName,
-                              &DeviceNode->ServiceName);
-
 done:
     if (ServiceEnumKey != NULL)
         ZwClose(ServiceEnumKey);

Reply via email to