[ros-diffs] [ion] 22651: - Fix another critical bug in ObInsertObject: don't overwrite the lookup status with the handle creation status. If the lookup returned something like OBJECT_NAME_EXISTS (which is a success + warning), we don't want to overwrite it with ObpCreateHandle's STATUS_SUCCESS. This should fix a large number of regressions (and also fixes many WINE ntdll "om" tests). - We also now correctly dereference the object in ObInsertObject, which should reduce one source of leaks (But there is still one). OTOH, this makes the Cm code crash at shutdown (I'll fix this ASAP, this fix is worth having atm.)

ion at svn.reactos.org ion at svn.reactos.org
Tue Jun 27 03:52:16 CEST 2006


Author: ion
Date: Tue Jun 27 05:52:16 2006
New Revision: 22651

URL: http://svn.reactos.org/svn/reactos?rev=22651&view=rev
Log:
- Fix another critical bug in ObInsertObject: don't overwrite the lookup status with the handle creation status. If the lookup returned something like OBJECT_NAME_EXISTS (which is a success + warning), we don't want to overwrite it with ObpCreateHandle's STATUS_SUCCESS. This should fix a large number of regressions (and also fixes many WINE ntdll "om" tests).
- We also now correctly dereference the object in ObInsertObject, which should reduce one source of leaks (But there is still one). OTOH, this makes the Cm code crash at shutdown (I'll fix this ASAP, this fix is worth having atm.)

Modified:
    trunk/reactos/ntoskrnl/ob/obhandle.c

Modified: trunk/reactos/ntoskrnl/ob/obhandle.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ob/obhandle.c?rev=22651&r1=22650&r2=22651&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/ob/obhandle.c (original)
+++ trunk/reactos/ntoskrnl/ob/obhandle.c Tue Jun 27 05:52:16 2006
@@ -1705,7 +1705,7 @@
     POBJECT_TYPE ObjectType;
     PVOID FoundObject = NULL;
     POBJECT_HEADER FoundHeader = NULL;
-    NTSTATUS Status = STATUS_SUCCESS;
+    NTSTATUS Status = STATUS_SUCCESS, RealStatus;
     PSECURITY_DESCRIPTOR DirectorySd = NULL;
     BOOLEAN SdAllocated;
     OBP_LOOKUP_CONTEXT Context;
@@ -1749,9 +1749,14 @@
         Header->ObjectCreateInfo = NULL;
 
         /* Remove the extra keep-alive reference */
-        //ObDereferenceObject(Object); // FIXME: Needs sync changes
+        if (Handle) ObDereferenceObject(Object); // FIXME: Needs sync changes
 
         /* Return */
+        OBTRACE(OB_HANDLE_DEBUG,
+                "%s - returning Object with PC S: %lx %lx\n",
+                __FUNCTION__,
+                OBJECT_TO_OBJECT_HEADER(Object)->PointerCount,
+                Status);
         return Status;
     }
 
@@ -1893,12 +1898,15 @@
         }
     }
 
+    /* Save the actual status until here */
+    RealStatus = Status;
+
     /* HACKHACK: Because of ROS's incorrect startup, this can be called
-    * without a valid Process until I finalize the startup patch,
-    * so don't create a handle if this is the case. We also don't create
-    * a handle if Handle is NULL when the Registry Code calls it, because
-    * the registry code totally bastardizes the Ob and needs to be fixed
-    */
+     * without a valid Process until I finalize the startup patch,
+     * so don't create a handle if this is the case. We also don't create
+     * a handle if Handle is NULL when the Registry Code calls it, because
+     * the registry code totally bastardizes the Ob and needs to be fixed
+     */
     if (Handle)
     {
         /* Create the handle */
@@ -1925,7 +1933,15 @@
     }
 
     /* Remove the extra keep-alive reference */
-    //ObDereferenceObject(Object);
+    if (Handle) ObDereferenceObject(Object);
+
+    /* Check our final status */
+    if (!NT_SUCCESS(Status))
+    {
+        /* Return the status of the failure */
+        *Handle = NULL;
+        RealStatus = Status;
+    }
 
     /* Check if we created our own access state */
     if (PassedAccessState == &AccessState)
@@ -1934,8 +1950,13 @@
         SeDeleteAccessState(PassedAccessState);
     }
 
-    /* Return failure code */
-    return Status;
+    /* Return status code */
+    OBTRACE(OB_HANDLE_DEBUG,
+            "%s - returning Object with PC S/RS: %lx %lx %lx\n",
+            __FUNCTION__,
+            OBJECT_TO_OBJECT_HEADER(Object)->PointerCount,
+            RealStatus, Status);
+    return RealStatus;
 }
 
 /*++




More information about the Ros-diffs mailing list