Call freeaddrinfo on error paths in net_getipport.

Without these, we'll have a memory leak on error paths.
This commit is contained in:
iphydf 2018-01-10 13:33:14 +00:00
parent 6c523f9f48
commit 79d8a22b48
No known key found for this signature in database
GPG Key ID: 3855DBA2D74403C9

View File

@ -1273,12 +1273,14 @@ int32_t net_getipport(const char *node, IP_Port **res, int tox_type)
assert(count <= MAX_COUNT); assert(count <= MAX_COUNT);
if (count == 0) { if (count == 0) {
freeaddrinfo(infos);
return 0; return 0;
} }
*res = (IP_Port *)malloc(sizeof(IP_Port) * count); *res = (IP_Port *)malloc(sizeof(IP_Port) * count);
if (*res == NULL) { if (*res == NULL) {
freeaddrinfo(infos);
return -1; return -1;
} }