Skip to content

Commit

Permalink
GUACAMOLE-377: Restore original NULL returns for alloc failures of st…
Browse files Browse the repository at this point in the history
…reams/objects.
  • Loading branch information
mike-jumper committed Sep 28, 2024
1 parent db42844 commit ed38863
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/libguac/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
10 changes: 6 additions & 4 deletions src/libguac/user.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down Expand Up @@ -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]);
Expand Down

0 comments on commit ed38863

Please sign in to comment.