Skip to content

Commit

Permalink
A bunch of NULL-pointer checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Barracuda72 committed Nov 9, 2017
1 parent 5827c13 commit bf5275e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
15 changes: 15 additions & 0 deletions ntoskrnl/ex/handle.c
Expand Up @@ -68,12 +68,20 @@ ExpLookupHandleTableEntry(IN PHANDLE_TABLE HandleTable,
/* Get the mid level pointer array */
PointerArray = PointerArray[Handle.HighIndex];

/* TODO: maybe ASSERT? */
if (PointerArray == NULL)
return NULL;

/* Fall through */
case 1:

/* Get the handle array */
HandleArray = PointerArray[Handle.MidIndex];

/* TODO: maybe ASSERT? */
if (HandleArray == NULL)
return NULL;

/* Fall through */
case 0:

Expand Down Expand Up @@ -708,6 +716,13 @@ ExpAllocateHandleTableEntry(IN PHANDLE_TABLE HandleTable,
/* Lookup the entry for this handle */
Entry = ExpLookupHandleTableEntry(HandleTable, Handle);

/* TODO: maybe ASSERT? */
if (Entry == NULL)
{
NewHandle->GenericHandleOverlay = NULL;
return NULL;
}

/* Get an available lock and acquire it */
i = ((OldValue & FREE_HANDLE_MASK) >> 2) % 4;
KeEnterCriticalRegion();
Expand Down
3 changes: 3 additions & 0 deletions ntoskrnl/ex/work.c
Expand Up @@ -305,6 +305,9 @@ ExpCreateWorkerThread(WORK_QUEUE_TYPE WorkQueueType,
(PVOID*)&Thread,
NULL);

if (Thread == NULL)
return;

/* Set the Priority */
KeSetBasePriorityThread(&Thread->Tcb, Priority);

Expand Down

0 comments on commit bf5275e

Please sign in to comment.