mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Free ports when there are no valid ones
This commit is contained in:
parent
0444ca18df
commit
09302e8909
|
@ -161,7 +161,12 @@ void parse_tcp_relay_ports_config(config_t *cfg, uint16_t **tcp_relay_ports, int
|
|||
}
|
||||
|
||||
// the loop above skips invalid ports, so we adjust the allocated memory size
|
||||
*tcp_relay_ports = realloc(*tcp_relay_ports, (*tcp_relay_port_count) * sizeof(uint16_t));
|
||||
if ((*tcp_relay_port_count) > 0) {
|
||||
*tcp_relay_ports = realloc(*tcp_relay_ports, (*tcp_relay_port_count) * sizeof(uint16_t));
|
||||
} else {
|
||||
free(*tcp_relay_port);
|
||||
*tcp_relay_port = NULL;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -210,8 +215,11 @@ void parse_tcp_relay_ports_config(config_t *cfg, uint16_t **tcp_relay_ports, int
|
|||
}
|
||||
|
||||
// the loop above skips invalid ports, so we adjust the allocated memory size
|
||||
if ((*tcp_relay_port_count) * sizeof(uint16_t) > 0) {
|
||||
if ((*tcp_relay_port_count) > 0) {
|
||||
*tcp_relay_ports = realloc(*tcp_relay_ports, (*tcp_relay_port_count) * sizeof(uint16_t));
|
||||
} else {
|
||||
free(*tcp_relay_port);
|
||||
*tcp_relay_port = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user