Track readbuf free's

As tcp_connection_destroy() might be called more than once per connection (depending on outstanding work)
This commit is contained in:
Willem Toorop 2018-01-22 16:32:17 +01:00
parent 155b035cd8
commit d38f233a80
1 changed files with 11 additions and 4 deletions

View File

@ -138,11 +138,18 @@ static void tcp_connection_destroy(tcp_connection *conn)
if (conn->fd >= 0)
(void) _getdns_closesocket(conn->fd);
GETDNS_FREE(*mf, conn->read_buf);
for (cur = conn->to_write; cur; cur = next) {
next = cur->next;
GETDNS_FREE(*mf, cur);
if (conn->read_buf) {
GETDNS_FREE(*mf, conn->read_buf);
conn->read_buf = NULL;
}
if ((cur = conn->to_write)) {
while (cur) {
next = cur->next;
GETDNS_FREE(*mf, cur);
cur = next;
}
conn->to_write = NULL;
}
if (conn->to_answer > 0)
return;