* [PATCH] libcody: Avoid double-free
@ 2021-10-21 13:27 Jonathan Wakely
2021-10-21 13:30 ` Jonathan Wakely
2021-10-21 19:34 ` Jason Merrill
0 siblings, 2 replies; 3+ messages in thread
From: Jonathan Wakely @ 2021-10-21 13:27 UTC (permalink / raw)
To: libstdc++, gcc-patches
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 30202c5106a..0499b5790b4 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.31.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] libcody: Avoid double-free
2021-10-21 13:27 [PATCH] libcody: Avoid double-free Jonathan Wakely
@ 2021-10-21 13:30 ` Jonathan Wakely
2021-10-21 19:34 ` Jason Merrill
1 sibling, 0 replies; 3+ messages in thread
From: Jonathan Wakely @ 2021-10-21 13:30 UTC (permalink / raw)
To: libstdc++; +Cc: gcc Patches, Jason Merrill
Oops, this patch and the next one were only meant for gcc-patches, not the
libstdc++ list as well - sorry!
On Thu, 21 Oct 2021 at 14:27, Jonathan Wakely via Libstdc++ <
libstdc++@gcc.gnu.org> wrote:
> 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 30202c5106a..0499b5790b4 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.31.1
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] libcody: Avoid double-free
2021-10-21 13:27 [PATCH] libcody: Avoid double-free Jonathan Wakely
2021-10-21 13:30 ` Jonathan Wakely
@ 2021-10-21 19:34 ` Jason Merrill
1 sibling, 0 replies; 3+ messages in thread
From: Jason Merrill @ 2021-10-21 19:34 UTC (permalink / raw)
To: Jonathan Wakely, gcc-patches
On 10/21/21 09:27, Jonathan Wakely wrote:
> 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.
OK.
> 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 30202c5106a..0499b5790b4 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)
> {
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-10-21 19:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-21 13:27 [PATCH] libcody: Avoid double-free Jonathan Wakely
2021-10-21 13:30 ` Jonathan Wakely
2021-10-21 19:34 ` Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).