aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2021-10-21 14:17:43 +0100
committerJonathan Wakely <jwakely@redhat.com>2021-10-21 22:23:00 +0100
commite6d100354317475412161a487ffbcf36582115c5 (patch)
tree9a23232d30c73bbdb763779027fea2f636516bdb
parent1373066a46d8d47abd97e46a005aef3b3dbfe94a (diff)
downloadgcc-e6d100354317475412161a487ffbcf36582115c5.zip
gcc-e6d100354317475412161a487ffbcf36582115c5.tar.gz
gcc-e6d100354317475412161a487ffbcf36582115c5.tar.bz2
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.
-rw-r--r--libcody/netserver.cc1
1 files changed, 1 insertions, 0 deletions
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)
{