Fixed the dereferencing of an existing named object in IoCreateFile.
Modified: trunk/reactos/ntoskrnl/io/create.c

Modified: trunk/reactos/ntoskrnl/io/create.c
--- trunk/reactos/ntoskrnl/io/create.c	2005-04-09 09:37:32 UTC (rev 14560)
+++ trunk/reactos/ntoskrnl/io/create.c	2005-04-09 09:40:44 UTC (rev 14561)
@@ -344,8 +344,8 @@
 	     IN	PVOID			ExtraCreateParameters	OPTIONAL,
 	     IN	ULONG			Options)
 {
-   PFILE_OBJECT		FileObject;
-   PDEVICE_OBJECT	DeviceObject = NULL;
+   PFILE_OBJECT		FileObject = NULL;
+   PDEVICE_OBJECT	DeviceObject;
    PIRP			Irp;
    PIO_STACK_LOCATION	StackLoc;
    IO_SECURITY_CONTEXT  SecurityContext;
@@ -460,23 +460,23 @@
 					    AccessMode,
 					    (PVOID*)&DeviceObject,
 					    NULL);
-	 ObDereferenceObject (DeviceObject);
+         ZwClose(LocalHandle); 
 	 if (!NT_SUCCESS(Status))
 	 {
 	    return Status;
 	 }
          if (BODY_TO_HEADER(DeviceObject)->ObjectType != IoDeviceObjectType)
 	 {
-            ZwClose(LocalHandle); 
+	    ObDereferenceObject (DeviceObject);
 	    return STATUS_OBJECT_NAME_COLLISION;
 	 }
          FileObject = IoCreateStreamFileObject(NULL, DeviceObject);
-         ZwClose(LocalHandle);
+	 ObDereferenceObject (DeviceObject);
       }
    }
 
 
-   if (DeviceObject == NULL)
+   if (FileObject == NULL)
    {
       Status = ObCreateObject(AccessMode,
 			      IoFileObjectType,