Fix resource leaks
This commit is contained in:
parent
39498beffd
commit
8dc47c6750
|
@ -708,6 +708,8 @@ static void start_listen(struct event_base *evbase, const char *service,
|
|||
LEV_OPT_REUSEABLE, 16,
|
||||
rp->ai_addr, rp->ai_addrlen);
|
||||
if(listener) {
|
||||
freeaddrinfo(res);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1334,6 +1334,8 @@ int nghttp2_hd_deflate_new(nghttp2_hd_deflater **deflater_ptr,
|
|||
rv = nghttp2_hd_deflate_init2(deflater, deflate_hd_table_bufsize_max);
|
||||
|
||||
if(rv != 0) {
|
||||
free(deflater);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -2045,6 +2047,8 @@ int nghttp2_hd_inflate_new(nghttp2_hd_inflater **inflater_ptr)
|
|||
rv = nghttp2_hd_inflate_init(inflater);
|
||||
|
||||
if(rv != 0) {
|
||||
free(inflater);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
22
src/shrpx.cc
22
src/shrpx.cc
|
@ -110,16 +110,20 @@ int resolve_hostname(sockaddr_union *addr, size_t *addrlen,
|
|||
char host[NI_MAXHOST];
|
||||
rv = getnameinfo(res->ai_addr, res->ai_addrlen, host, sizeof(host),
|
||||
0, 0, NI_NUMERICHOST);
|
||||
if(rv == 0) {
|
||||
if(LOG_ENABLED(INFO)) {
|
||||
LOG(INFO) << "Address resolution for " << hostname << " succeeded: "
|
||||
<< host;
|
||||
}
|
||||
} else {
|
||||
if(rv != 0) {
|
||||
LOG(FATAL) << "Address resolution for " << hostname << " failed: "
|
||||
<< gai_strerror(rv);
|
||||
|
||||
freeaddrinfo(res);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(LOG_ENABLED(INFO)) {
|
||||
LOG(INFO) << "Address resolution for " << hostname << " succeeded: "
|
||||
<< host;
|
||||
}
|
||||
|
||||
memcpy(addr, res->ai_addr, res->ai_addrlen);
|
||||
*addrlen = res->ai_addrlen;
|
||||
freeaddrinfo(res);
|
||||
|
@ -194,6 +198,8 @@ evconnlistener* create_evlistener(ListenHandler *handler, int family)
|
|||
LOG(WARNING) << "Listening " << (family == AF_INET ? "IPv4" : "IPv6")
|
||||
<< " socket failed";
|
||||
|
||||
freeaddrinfo(res);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -201,6 +207,8 @@ evconnlistener* create_evlistener(ListenHandler *handler, int family)
|
|||
rv = getnameinfo(rp->ai_addr, rp->ai_addrlen, host, sizeof(host),
|
||||
nullptr, 0, NI_NUMERICHOST);
|
||||
|
||||
freeaddrinfo(res);
|
||||
|
||||
if(rv != 0) {
|
||||
LOG(WARNING) << gai_strerror(rv);
|
||||
|
||||
|
@ -213,8 +221,6 @@ evconnlistener* create_evlistener(ListenHandler *handler, int family)
|
|||
LOG(INFO) << "Listening on " << host << ", port " << get_config()->port;
|
||||
}
|
||||
|
||||
freeaddrinfo(res);
|
||||
|
||||
auto evlistener = evconnlistener_new
|
||||
(handler->get_evbase(),
|
||||
ssl_acceptcb,
|
||||
|
|
Loading…
Reference in New Issue