don't attempt to reference NULL objects in NtIsProcessInJob()

svn path=/trunk/; revision=11019
This commit is contained in:
Thomas Bluemel 2004-09-23 22:02:39 +00:00
parent b50f152bc1
commit 5b552386bc

View file

@ -121,10 +121,12 @@ NtIsProcessInJob(IN HANDLE ProcessHandle,
if(NT_SUCCESS(Status)) if(NT_SUCCESS(Status))
{ {
/* FIXME - make sure the job object doesn't get exchanged or deleted while trying to /* FIXME - make sure the job object doesn't get exchanged or deleted while trying to
reference it, e.g. by locking it somehow... */ reference it, e.g. by locking it somehow until it is referenced... */
PEJOB ProcessJob = Process->Job; PEJOB ProcessJob = Process->Job;
if(ProcessJob != NULL)
{
/* reference the object without caring about access rights as it does not necessarily /* reference the object without caring about access rights as it does not necessarily
have to be accessible from the calling process */ have to be accessible from the calling process */
Status = ObReferenceObjectByPointer(ProcessJob, Status = ObReferenceObjectByPointer(ProcessJob,
@ -136,9 +138,9 @@ NtIsProcessInJob(IN HANDLE ProcessHandle,
if(JobHandle == NULL) if(JobHandle == NULL)
{ {
/* simply test whether the process is assigned to a job */ /* simply test whether the process is assigned to a job */
Status = ((Process->Job != NULL) ? STATUS_PROCESS_IN_JOB : STATUS_PROCESS_NOT_IN_JOB); Status = ((ProcessJob != NULL) ? STATUS_PROCESS_IN_JOB : STATUS_PROCESS_NOT_IN_JOB);
} }
else if(ProcessJob != NULL) else /* JobHandle != NULL */
{ {
PEJOB JobObject; PEJOB JobObject;
@ -155,14 +157,15 @@ NtIsProcessInJob(IN HANDLE ProcessHandle,
ObDereferenceObject(JobObject); ObDereferenceObject(JobObject);
} }
} }
ObDereferenceObject(ProcessJob);
}
}
else else
{ {
/* the process is not assigned to any job */ /* the process is not assigned to any job */
Status = STATUS_PROCESS_NOT_IN_JOB; Status = STATUS_PROCESS_NOT_IN_JOB;
} }
ObDereferenceObject(ProcessJob);
}
ObDereferenceObject(Process); ObDereferenceObject(Process);
} }