From c976db1a0388f9233f72ceab495d6eefc2b72618 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 13 Jul 2005 12:09:49 +0000 Subject: [PATCH] Avoid potential crashes when there is no handle table. --- server/handle.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/server/handle.c b/server/handle.c index 287efc2d409..f170374bbc5 100644 --- a/server/handle.c +++ b/server/handle.c @@ -221,12 +221,14 @@ static obj_handle_t alloc_entry( struct handle_table *table, void *obj, unsigned /* return the handle, or 0 on error */ obj_handle_t alloc_handle( struct process *process, void *obj, unsigned int access, int inherit ) { - struct handle_table *table = process->handles; - - assert( table ); - assert( !(access & RESERVED_ALL) ); + access &= ~RESERVED_ALL; 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 */ @@ -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 */ unsigned int get_handle_table_count( struct process *process ) { + if (!process->handles) return 0; return process->handles->count; } -- 2.11.4.GIT