From 2df986f6b951aee49f403ff076f213213ce873eb Mon Sep 17 00:00:00 2001 From: Sean Qureshi Date: Fri, 10 Oct 2014 18:23:23 -0700 Subject: [PATCH] Does a realloc with a size of 0 if every port is invalid --- other/bootstrap_daemon/tox-bootstrapd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/other/bootstrap_daemon/tox-bootstrapd.c b/other/bootstrap_daemon/tox-bootstrapd.c index 0848cd177..a0f93bb33 100644 --- a/other/bootstrap_daemon/tox-bootstrapd.c +++ b/other/bootstrap_daemon/tox-bootstrapd.c @@ -210,7 +210,9 @@ 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) * sizeof(uint16_t) > 0) { + *tcp_relay_ports = realloc(*tcp_relay_ports, (*tcp_relay_port_count) * sizeof(uint16_t)); + } } // Gets general config options