Skip to content

Commit

Permalink
Free addrinfo struct on getaddrinfo() errors
Browse files Browse the repository at this point in the history
  • Loading branch information
stephane committed Jan 24, 2024
1 parent e6b71a8 commit 196ae76
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/modbus-tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ static int _modbus_tcp_pi_connect(modbus_t *ctx)
if (ctx->debug) {
fprintf(stderr, "Error returned by getaddrinfo: %s\n", gai_strerror(rc));
}
freeaddrinfo(ai_list);
errno = ECONNREFUSED;
return -1;
}
Expand Down Expand Up @@ -628,6 +629,7 @@ int modbus_tcp_pi_listen(modbus_t *ctx, int nb_connection)
if (ctx->debug) {
fprintf(stderr, "Error returned by getaddrinfo: %s\n", gai_strerror(rc));
}
freeaddrinfo(ai_list);
errno = ECONNREFUSED;
return -1;
}
Expand Down

0 comments on commit 196ae76

Please sign in to comment.