From e6d100354317475412161a487ffbcf36582115c5 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Thu, 21 Oct 2021 14:17:43 +0100 Subject: [PATCH] libcody: Avoid double-free If the listen call fails then 'goto fail' will jump to that label and use freeaddrinfo again. Set the pointer to null to prevent that. libcody/ChangeLog: * netserver.cc (ListenInet6): Set pointer to null after deallocation. --- libcody/netserver.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/libcody/netserver.cc b/libcody/netserver.cc index 30202c5..0499b57 100644 --- a/libcody/netserver.cc +++ b/libcody/netserver.cc @@ -140,6 +140,7 @@ int ListenInet6 (char const **e, char const *name, int port, unsigned backlog) listen:; freeaddrinfo (addrs); + addrs = nullptr; if (listen (fd, backlog ? backlog : 17) < 0) { -- 2.7.4