]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
daemon/io: freed handle could be touched in libuv
authorMarek Vavrusa <marek@vavrusa.com>
Sun, 29 May 2016 20:27:19 +0000 (13:27 -0700)
committerMarek Vavrusa <marek@vavrusa.com>
Sun, 29 May 2016 20:27:19 +0000 (13:27 -0700)
the daemon wrongly freed handle that returned 0,
as in "no more data". this socket is going to be
closed, but it still could be touched by libuv
so it must be freed wit uv_close() handler

daemon/io.c

index c2df007a73475f083ab044f06725c234b08e396d..5ab83daeb45aed30ed43deb3eff2f4f581e6af4c 100644 (file)
@@ -215,7 +215,7 @@ static void tcp_accept(uv_stream_t *master, int status)
        memset(client, 0, sizeof(*client));
        io_create(master->loop, (uv_handle_t *)client, SOCK_STREAM);
        if (uv_accept(master, client) != 0) {
-               io_free((uv_handle_t *)client);
+               uv_close((uv_handle_t *)client, io_free);
                return;
        }