diff --git a/include/corosync/hdb.h b/include/corosync/hdb.h index c1eb227d..79151ebc 100644 --- a/include/corosync/hdb.h +++ b/include/corosync/hdb.h @@ -243,14 +243,6 @@ static inline int hdb_handle_get ( hdb_database_lock (&handle_database->lock); - if (check != 0xffffffff && - check != handle_database->handles[handle].check) { - - hdb_database_unlock (&handle_database->lock); - errno = EBADF; - return (-1); - } - *instance = NULL; if (handle >= handle_database->handle_count) { hdb_database_unlock (&handle_database->lock); @@ -264,6 +256,14 @@ static inline int hdb_handle_get ( return (-1); } + if (check != 0xffffffff && + check != handle_database->handles[handle].check) { + + hdb_database_unlock (&handle_database->lock); + errno = EBADF; + return (-1); + } + *instance = handle_database->handles[handle].instance; handle_database->handles[handle].ref_count += 1; @@ -281,6 +281,13 @@ static inline int hdb_handle_put ( hdb_database_lock (&handle_database->lock); + if (handle >= handle_database->handle_count) { + hdb_database_unlock (&handle_database->lock); + + errno = EBADF; + return (-1); + } + if (check != 0xffffffff && check != handle_database->handles[handle].check) { @@ -313,6 +320,13 @@ static inline int hdb_handle_destroy ( hdb_database_lock (&handle_database->lock); + if (handle >= handle_database->handle_count) { + hdb_database_unlock (&handle_database->lock); + + errno = EBADF; + return (-1); + } + if (check != 0xffffffff && check != handle_database->handles[handle].check) { hdb_database_unlock (&handle_database->lock);