diff --git a/src/libguac/client.c b/src/libguac/client.c index ab8a07c1d..71fa7f763 100644 --- a/src/libguac/client.c +++ b/src/libguac/client.c @@ -128,8 +128,9 @@ guac_stream* guac_client_alloc_stream(guac_client* client) { int stream_index; /* Allocate stream, but refuse to allocate beyond maximum */ - stream_index = guac_pool_next_int_below_or_die(client->__stream_pool, - GUAC_CLIENT_MAX_STREAMS); + stream_index = guac_pool_next_int_below(client->__stream_pool, GUAC_CLIENT_MAX_STREAMS); + if (stream_index < 0) + return NULL; /* Initialize stream with odd index (even indices are user-level) */ allocd_stream = &(client->__output_streams[stream_index]); diff --git a/src/libguac/user.c b/src/libguac/user.c index 160e27478..16baa169f 100644 --- a/src/libguac/user.c +++ b/src/libguac/user.c @@ -108,8 +108,9 @@ guac_stream* guac_user_alloc_stream(guac_user* user) { int stream_index; /* Allocate stream, but refuse to allocate beyond maximum */ - stream_index = guac_pool_next_int_below_or_die(user->__stream_pool, - GUAC_USER_MAX_STREAMS); + stream_index = guac_pool_next_int_below(user->__stream_pool, GUAC_USER_MAX_STREAMS); + if (stream_index < 0) + return NULL; /* Initialize stream with even index (odd indices are client-level) */ allocd_stream = &(user->__output_streams[stream_index]); @@ -139,8 +140,9 @@ guac_object* guac_user_alloc_object(guac_user* user) { int object_index; /* Allocate object, but refuse to allocate beyond maximum */ - object_index = guac_pool_next_int_below_or_die(user->__object_pool, - GUAC_USER_MAX_OBJECTS); + object_index = guac_pool_next_int_below(user->__object_pool, GUAC_USER_MAX_OBJECTS); + if (object_index < 0) + return NULL; /* Initialize object */ allocd_object = &(user->__objects[object_index]);