Avoid potential crashes when there is no handle table.
This commit is contained in:
parent
7258914ef6
commit
c976db1a03
|
@ -221,12 +221,14 @@ static obj_handle_t alloc_entry( struct handle_table *table, void *obj, unsigned
|
||||||
/* return the handle, or 0 on error */
|
/* return the handle, or 0 on error */
|
||||||
obj_handle_t alloc_handle( struct process *process, void *obj, unsigned int access, int inherit )
|
obj_handle_t alloc_handle( struct process *process, void *obj, unsigned int access, int inherit )
|
||||||
{
|
{
|
||||||
struct handle_table *table = process->handles;
|
access &= ~RESERVED_ALL;
|
||||||
|
|
||||||
assert( table );
|
|
||||||
assert( !(access & RESERVED_ALL) );
|
|
||||||
if (inherit) access |= RESERVED_INHERIT;
|
if (inherit) access |= RESERVED_INHERIT;
|
||||||
return alloc_entry( table, obj, access );
|
if (!process->handles)
|
||||||
|
{
|
||||||
|
set_error( STATUS_NO_MEMORY );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return alloc_entry( process->handles, obj, access );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* allocate a global handle for an object, incrementing its refcount */
|
/* allocate a global handle for an object, incrementing its refcount */
|
||||||
|
@ -530,6 +532,7 @@ obj_handle_t open_object( const struct namespace *namespace, const WCHAR *name,
|
||||||
/* return the size of the handle table of a given process */
|
/* return the size of the handle table of a given process */
|
||||||
unsigned int get_handle_table_count( struct process *process )
|
unsigned int get_handle_table_count( struct process *process )
|
||||||
{
|
{
|
||||||
|
if (!process->handles) return 0;
|
||||||
return process->handles->count;
|
return process->handles->count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue