From 79d8a22b4811083daf0a65fc94939b47c47997b7 Mon Sep 17 00:00:00 2001 From: iphydf Date: Wed, 10 Jan 2018 13:33:14 +0000 Subject: [PATCH] Call freeaddrinfo on error paths in net_getipport. Without these, we'll have a memory leak on error paths. --- toxcore/network.c | 2 ++ 1 file changed, 2 insertions(+) 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) assert(count <= MAX_COUNT); if (count == 0) { + freeaddrinfo(infos); return 0; } *res = (IP_Port *)malloc(sizeof(IP_Port) * count); if (*res == NULL) { + freeaddrinfo(infos); return -1; }