- Check first for a valid returned object in ObOpenObjectByName.  
- Free always the remaining path string if an error is returned in ObOpenObjectByName.
Modified: trunk/reactos/ntoskrnl/ob/namespc.c

Modified: trunk/reactos/ntoskrnl/ob/namespc.c
--- trunk/reactos/ntoskrnl/ob/namespc.c	2005-05-02 16:35:58 UTC (rev 14949)
+++ trunk/reactos/ntoskrnl/ob/namespc.c	2005-05-02 19:12:31 UTC (rev 14950)
@@ -143,15 +143,21 @@
 	return Status;
      }
 
+   if (Object == NULL)
+     {
+       RtlFreeUnicodeString(&RemainingPath);
+       return STATUS_UNSUCCESSFUL;
+     }
    if (RemainingPath.Buffer != NULL)
    {
       if (wcschr(RemainingPath.Buffer + 1, L'\\') == NULL)
-         return STATUS_OBJECT_NAME_NOT_FOUND;
+         Status = STATUS_OBJECT_NAME_NOT_FOUND;
       else
-         return STATUS_OBJECT_PATH_NOT_FOUND;
+         Status =STATUS_OBJECT_PATH_NOT_FOUND;
+      RtlFreeUnicodeString(&RemainingPath);
+      ObDereferenceObject(Object);
+      return Status;
    }
-   if (Object == NULL)
-      return STATUS_UNSUCCESSFUL;
 
    Status = ObCreateHandle(PsGetCurrentProcess(),
 			   Object,