diff options
author | iphydf <iphydf@users.noreply.github.com> | 2018-01-10 13:33:14 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2018-01-10 18:57:17 +0000 |
commit | 79d8a22b4811083daf0a65fc94939b47c47997b7 (patch) | |
tree | 4bd8042fbb6dc1eaa2f6f7b2b6825ad62e05dc69 /toxcore/network.c | |
parent | 6c523f9f48e64362bb7d191ba54c7c56be5b10c0 (diff) |
Call freeaddrinfo on error paths in net_getipport.
Without these, we'll have a memory leak on error paths.
Diffstat (limited to 'toxcore/network.c')
-rw-r--r-- | toxcore/network.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/toxcore/network.c b/toxcore/network.c index 7587826b..c3efba81 100644 --- a/toxcore/network.c +++ b/toxcore/network.c | |||
@@ -1273,12 +1273,14 @@ int32_t net_getipport(const char *node, IP_Port **res, int tox_type) | |||
1273 | assert(count <= MAX_COUNT); | 1273 | assert(count <= MAX_COUNT); |
1274 | 1274 | ||
1275 | if (count == 0) { | 1275 | if (count == 0) { |
1276 | freeaddrinfo(infos); | ||
1276 | return 0; | 1277 | return 0; |
1277 | } | 1278 | } |
1278 | 1279 | ||
1279 | *res = (IP_Port *)malloc(sizeof(IP_Port) * count); | 1280 | *res = (IP_Port *)malloc(sizeof(IP_Port) * count); |
1280 | 1281 | ||
1281 | if (*res == NULL) { | 1282 | if (*res == NULL) { |
1283 | freeaddrinfo(infos); | ||
1282 | return -1; | 1284 | return -1; |
1283 | } | 1285 | } |
1284 | 1286 | ||