mirror of
https://github.com/libevent/libevent.git
synced 2025-01-31 09:12:55 +08:00
Fix resource leaks in the unit tests; found by coverity
This commit is contained in:
parent
4f3732d75e
commit
270f279fb5
@ -2660,9 +2660,11 @@ http_chunked_errorcb(struct bufferevent *bev, short what, void *arg)
|
|||||||
if (header == NULL)
|
if (header == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
/* 13 chars */
|
/* 13 chars */
|
||||||
if (strcmp(header, "d"))
|
if (strcmp(header, "d")) {
|
||||||
|
free((void*)header);
|
||||||
goto out;
|
goto out;
|
||||||
free((char*)header);
|
}
|
||||||
|
free((void*)header);
|
||||||
|
|
||||||
if (strncmp((char *)evbuffer_pullup(bufferevent_get_input(bev), 13),
|
if (strncmp((char *)evbuffer_pullup(bufferevent_get_input(bev), 13),
|
||||||
"This is funny", 13))
|
"This is funny", 13))
|
||||||
@ -2688,8 +2690,10 @@ http_chunked_errorcb(struct bufferevent *bev, short what, void *arg)
|
|||||||
if (header == NULL)
|
if (header == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
/* 8 chars */
|
/* 8 chars */
|
||||||
if (strcmp(header, "8"))
|
if (strcmp(header, "8")) {
|
||||||
|
free((void*)header);
|
||||||
goto out;
|
goto out;
|
||||||
|
}
|
||||||
free((char *)header);
|
free((char *)header);
|
||||||
|
|
||||||
if (strncmp((char *)evbuffer_pullup(bufferevent_get_input(bev), 8),
|
if (strncmp((char *)evbuffer_pullup(bufferevent_get_input(bev), 8),
|
||||||
@ -2702,9 +2706,11 @@ http_chunked_errorcb(struct bufferevent *bev, short what, void *arg)
|
|||||||
if (header == NULL)
|
if (header == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
/* 0 chars */
|
/* 0 chars */
|
||||||
if (strcmp(header, "0"))
|
if (strcmp(header, "0")) {
|
||||||
|
free((void*)header);
|
||||||
goto out;
|
goto out;
|
||||||
free((char *)header);
|
}
|
||||||
|
free((void *)header);
|
||||||
|
|
||||||
test_ok = 2;
|
test_ok = 2;
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ regress_get_dnsserver(struct event_base *base,
|
|||||||
struct sockaddr_in my_addr;
|
struct sockaddr_in my_addr;
|
||||||
|
|
||||||
sock = socket(AF_INET, SOCK_DGRAM, 0);
|
sock = socket(AF_INET, SOCK_DGRAM, 0);
|
||||||
if (sock <= 0) {
|
if (sock < 0) {
|
||||||
tt_abort_perror("socket");
|
tt_abort_perror("socket");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,6 +113,7 @@ regress_get_dnsserver(struct event_base *base,
|
|||||||
my_addr.sin_port = htons(*portnum);
|
my_addr.sin_port = htons(*portnum);
|
||||||
my_addr.sin_addr.s_addr = htonl(0x7f000001UL);
|
my_addr.sin_addr.s_addr = htonl(0x7f000001UL);
|
||||||
if (bind(sock, (struct sockaddr*)&my_addr, sizeof(my_addr)) < 0) {
|
if (bind(sock, (struct sockaddr*)&my_addr, sizeof(my_addr)) < 0) {
|
||||||
|
evutil_closesocket(sock);
|
||||||
tt_abort_perror("bind");
|
tt_abort_perror("bind");
|
||||||
}
|
}
|
||||||
port = evdns_add_server_port_with_base(base, sock, 0, cb, arg);
|
port = evdns_add_server_port_with_base(base, sock, 0, cb, arg);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user