Skip to content

Commit

Permalink
happy-eyeballs: Reserve array length for all candidates
Browse files Browse the repository at this point in the history
The code currently assumes that the array does not change during
execution, this assumption is violated when the darray resizes causing
previous pointers to point to invalid memory and cause undefined
behavior and crashes.

This may need refactoring in the future, this commit simply fixes the
issue for now.
  • Loading branch information
notr1ch authored and RytoEX committed Aug 13, 2024
1 parent c7b0c63 commit fce5345
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions shared/happy-eyeballs/happy-eyeballs.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ int happy_eyeballs_create(struct happy_eyeballs_ctx **context)

ctx->socket_fd = INVALID_SOCKET;
da_init(ctx->candidates);
da_reserve(ctx->candidates, HAPPY_EYEBALLS_MAX_ATTEMPTS);

/* race_completed_event will be signalled when there is a winner or all
* attempts have failed */
Expand Down

0 comments on commit fce5345

Please sign in to comment.