summaryrefslogtreecommitdiff
path: root/other/bootstrap_daemon/tox-bootstrapd.c
diff options
context:
space:
mode:
authorMaxim Biro <nurupo.contributions@gmail.com>2014-10-12 19:20:58 -0400
committerMaxim Biro <nurupo.contributions@gmail.com>2014-10-12 19:21:22 -0400
commit09302e89096c70fece8d8e8d3a4b8acb236e397b (patch)
tree6c295b6239240525f538960bc83c9a494f8f23e6 /other/bootstrap_daemon/tox-bootstrapd.c
parent0444ca18dff821943aac9bc3a59207b2d0dea33f (diff)
Free ports when there are no valid ones
Diffstat (limited to 'other/bootstrap_daemon/tox-bootstrapd.c')
-rw-r--r--other/bootstrap_daemon/tox-bootstrapd.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/other/bootstrap_daemon/tox-bootstrapd.c b/other/bootstrap_daemon/tox-bootstrapd.c
index 7e78da4e..1b69014c 100644
--- a/other/bootstrap_daemon/tox-bootstrapd.c
+++ b/other/bootstrap_daemon/tox-bootstrapd.c
@@ -161,7 +161,12 @@ void parse_tcp_relay_ports_config(config_t *cfg, uint16_t **tcp_relay_ports, int
161 } 161 }
162 162
163 // the loop above skips invalid ports, so we adjust the allocated memory size 163 // the loop above skips invalid ports, so we adjust the allocated memory size
164 *tcp_relay_ports = realloc(*tcp_relay_ports, (*tcp_relay_port_count) * sizeof(uint16_t)); 164 if ((*tcp_relay_port_count) > 0) {
165 *tcp_relay_ports = realloc(*tcp_relay_ports, (*tcp_relay_port_count) * sizeof(uint16_t));
166 } else {
167 free(*tcp_relay_port);
168 *tcp_relay_port = NULL;
169 }
165 170
166 return; 171 return;
167 } 172 }
@@ -210,8 +215,11 @@ void parse_tcp_relay_ports_config(config_t *cfg, uint16_t **tcp_relay_ports, int
210 } 215 }
211 216
212 // the loop above skips invalid ports, so we adjust the allocated memory size 217 // the loop above skips invalid ports, so we adjust the allocated memory size
213 if ((*tcp_relay_port_count) * sizeof(uint16_t) > 0) { 218 if ((*tcp_relay_port_count) > 0) {
214 *tcp_relay_ports = realloc(*tcp_relay_ports, (*tcp_relay_port_count) * sizeof(uint16_t)); 219 *tcp_relay_ports = realloc(*tcp_relay_ports, (*tcp_relay_port_count) * sizeof(uint16_t));
220 } else {
221 free(*tcp_relay_port);
222 *tcp_relay_port = NULL;
215 } 223 }
216} 224}
217 225