- 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.)

svn path=/trunk/; revision=22651
This commit is contained in:
Alex Ionescu 2006-06-27 01:52:16 +00:00
parent e498da59d9
commit 7c3d15c5f9

View file

@ -1705,7 +1705,7 @@ ObInsertObject(IN PVOID Object,
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 @@ ObInsertObject(IN PVOID Object,
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 @@ ObInsertObject(IN PVOID Object,
}
}
/* 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 @@ ObInsertObject(IN PVOID Object,
}
/* 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 @@ ObInsertObject(IN PVOID Object,
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;
}
/*++