Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memory bug when obtaining a port number #518

Merged
merged 1 commit into from
Feb 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions core/federated/federate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1978,10 +1978,13 @@ void lf_connect_to_rti(const char* hostname, int port) {

void lf_create_server(int specified_port) {
assert(specified_port <= UINT16_MAX && specified_port >= 0);
if (create_server(specified_port, &_fed.server_socket, (uint16_t*)&_fed.server_port, TCP, false)) {
uint16_t final_port;
if (create_server(specified_port, &_fed.server_socket, &final_port, TCP, false)) {
lf_print_error_system_failure("RTI failed to create TCP server: %s.", strerror(errno));
};
LF_PRINT_LOG("Server for communicating with other federates started using port %d.", _fed.server_port);

LF_PRINT_LOG("Server for communicating with other federates started using port %u.", final_port);
_fed.server_port = final_port;

// Send the server port number to the RTI
// on an MSG_TYPE_ADDRESS_ADVERTISEMENT message (@see net_common.h).
Expand Down
Loading