From f4d7f3acd9b3472acd42ba278954939095a7202b Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Fri, 27 Sep 2024 19:25:29 -0700 Subject: [PATCH] GUACAMOLE-377: Remove superfluous bounds check (now part of guac_pool). --- src/libguac/client.c | 6 +----- src/libguac/user.c | 12 ++---------- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/src/libguac/client.c b/src/libguac/client.c index efe6d53ae..ab8a07c1d 100644 --- a/src/libguac/client.c +++ b/src/libguac/client.c @@ -127,11 +127,7 @@ guac_stream* guac_client_alloc_stream(guac_client* client) { guac_stream* allocd_stream; int stream_index; - /* Refuse to allocate beyond maximum */ - if (client->__stream_pool->active == GUAC_CLIENT_MAX_STREAMS) - return NULL; - - /* Allocate stream */ + /* Allocate stream, but refuse to allocate beyond maximum */ stream_index = guac_pool_next_int_below_or_die(client->__stream_pool, GUAC_CLIENT_MAX_STREAMS); diff --git a/src/libguac/user.c b/src/libguac/user.c index c2b320428..160e27478 100644 --- a/src/libguac/user.c +++ b/src/libguac/user.c @@ -107,11 +107,7 @@ guac_stream* guac_user_alloc_stream(guac_user* user) { guac_stream* allocd_stream; int stream_index; - /* Refuse to allocate beyond maximum */ - if (user->__stream_pool->active == GUAC_USER_MAX_STREAMS) - return NULL; - - /* Allocate stream */ + /* Allocate stream, but refuse to allocate beyond maximum */ stream_index = guac_pool_next_int_below_or_die(user->__stream_pool, GUAC_USER_MAX_STREAMS); @@ -142,11 +138,7 @@ guac_object* guac_user_alloc_object(guac_user* user) { guac_object* allocd_object; int object_index; - /* Refuse to allocate beyond maximum */ - if (user->__object_pool->active == GUAC_USER_MAX_OBJECTS) - return NULL; - - /* Allocate object */ + /* Allocate object, but refuse to allocate beyond maximum */ object_index = guac_pool_next_int_below_or_die(user->__object_pool, GUAC_USER_MAX_OBJECTS);