Fix a couple of small memory leaks, which may happen in error cases when loading configuration
This commit is contained in:
parent
d49d7bfeb0
commit
b8cdf3cbe4
|
|
@ -122,6 +122,8 @@ int acl_add(struct acl_t *acl, char *netspec, int allow)
|
|||
prefixlen = atoi(prefixls);
|
||||
if (prefixlen < 0 || prefixlen > 128) {
|
||||
hlog(LOG_ERR, "ACL: invalid prefix len '%s' for '%s'", prefixls, netspec);
|
||||
if (ai)
|
||||
freeaddrinfo(ai);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
@ -179,7 +181,7 @@ int acl_add(struct acl_t *acl, char *netspec, int allow)
|
|||
}
|
||||
|
||||
hfree(addr_s);
|
||||
hfree(ai);
|
||||
freeaddrinfo(ai);
|
||||
ai = nextai;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -489,6 +489,8 @@ int do_peergroup(struct peerip_config_t **lq, int argc, char **argv)
|
|||
char *peerid = NULL;
|
||||
char *fullhost, *host_s, *port_s;
|
||||
int af;
|
||||
|
||||
ai = my_ai = a = NULL;
|
||||
|
||||
if (argc < 4)
|
||||
return -1;
|
||||
|
|
@ -535,6 +537,7 @@ int do_peergroup(struct peerip_config_t **lq, int argc, char **argv)
|
|||
if (d != 1) {
|
||||
hlog(LOG_ERR, "PeerGroup: address parsing for local address %s returned %d addresses - can only have one", fullhost, d);
|
||||
hfree(fullhost);
|
||||
freeaddrinfo(my_ai);
|
||||
return -2;
|
||||
}
|
||||
|
||||
|
|
@ -626,6 +629,7 @@ int do_peergroup(struct peerip_config_t **lq, int argc, char **argv)
|
|||
fullhost = NULL;
|
||||
hfree(peerid);
|
||||
freeaddrinfo(ai);
|
||||
ai = NULL;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -665,6 +669,8 @@ err:
|
|||
hfree(fullhost);
|
||||
if (peerid)
|
||||
hfree(peerid);
|
||||
if (ai)
|
||||
freeaddrinfo(ai);
|
||||
|
||||
return -2;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue