[NTOS:EX] Don't dereference ExpCritSecOutOfMemoryEvent when it was never referenced.
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Sun, 22 Oct 2017 08:57:40 +0000 (10:57 +0200)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Thu, 4 Jan 2018 20:05:10 +0000 (21:05 +0100)
ntoskrnl/ex/keyedevt.c

index 6bb2769..110b2c3 100644 (file)
@@ -457,8 +457,11 @@ NtWaitForKeyedEvent(
     /* Do the wait */
     Status = ExpWaitForKeyedEvent(KeyedEvent, Key, Alertable, Timeout);
 
-    /* Dereference the keyed event */
-    ObDereferenceObject(KeyedEvent);
+    if (Handle != NULL)
+    {
+        /* Dereference the keyed event */
+        ObDereferenceObject(KeyedEvent);
+    }
 
     /* Return the status */
     return Status;
@@ -523,8 +526,11 @@ NtReleaseKeyedEvent(
     /* Do the wait */
     Status = ExpReleaseKeyedEvent(KeyedEvent, Key, Alertable, Timeout);
 
-    /* Dereference the keyed event */
-    ObDereferenceObject(KeyedEvent);
+    if (Handle != NULL)
+    {
+        /* Dereference the keyed event */
+        ObDereferenceObject(KeyedEvent);
+    }
 
     /* Return the status */
     return Status;