[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnunet] 09/28: fix memory leak
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnunet] 09/28: fix memory leak |
Date: |
Fri, 10 Mar 2017 18:18:53 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository gnunet.
commit 287be62e649091b608c0d7bcf77c4c633a24b4e7
Author: Christian Grothoff <address@hidden>
AuthorDate: Fri Mar 10 17:38:52 2017 +0100
fix memory leak
---
src/nat/gnunet-nat.c | 45 +++++++++++++++++++--------------------------
1 file changed, 19 insertions(+), 26 deletions(-)
diff --git a/src/nat/gnunet-nat.c b/src/nat/gnunet-nat.c
index c785fe210..04bde5111 100644
--- a/src/nat/gnunet-nat.c
+++ b/src/nat/gnunet-nat.c
@@ -269,8 +269,10 @@ run (void *cls,
global_ret = 1;
return;
}
- local_len = 0; /* make compilers happy */
+ local_len = 0;
local_sa = NULL;
+ remote_len = 0;
+ remote_sa = NULL;
if (NULL != local_addr)
{
local_len = (socklen_t) GNUNET_STRINGS_parse_socket_addr (local_addr,
@@ -281,13 +283,10 @@ run (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
"Invalid socket address `%s'\n",
local_addr);
- global_ret = 1;
- return;
+ goto fail_and_shutdown;
}
}
- remote_len = 0;
-
if (NULL != remote_addr)
{
remote_len = GNUNET_STRINGS_parse_socket_addr (remote_addr,
@@ -298,8 +297,7 @@ run (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
"Invalid socket address `%s'\n",
remote_addr);
- global_ret = 1;
- return;
+ goto fail_and_shutdown;
}
}
@@ -321,9 +319,7 @@ run (void *cls,
{
GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
"Use of `-W` only effective in combination with `-i`\n");
- global_ret = 1;
- GNUNET_SCHEDULER_shutdown ();
- return;
+ goto fail_and_shutdown;
}
if (NULL != remote_addr)
@@ -335,17 +331,13 @@ run (void *cls,
{
GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
"Require IPv4 local address to initiate connection
reversal\n");
- global_ret = 1;
- GNUNET_SCHEDULER_shutdown ();
- return;
+ goto fail_and_shutdown;
}
if (sizeof (struct sockaddr_in) != remote_len)
{
GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
"Require IPv4 reversal target address\n");
- global_ret = 1;
- GNUNET_SCHEDULER_shutdown ();
- return;
+ goto fail_and_shutdown;
}
GNUNET_assert (AF_INET == local_sa->sa_family);
GNUNET_assert (AF_INET == remote_sa->sa_family);
@@ -374,17 +366,13 @@ run (void *cls,
{
GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
"Require local address to support STUN requests\n");
- global_ret = 1;
- GNUNET_SCHEDULER_shutdown ();
- return;
+ goto fail_and_shutdown;
}
if (IPPROTO_UDP != proto)
{
GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
"STUN only supported over UDP\n");
- global_ret = 1;
- GNUNET_SCHEDULER_shutdown ();
- return;
+ goto fail_and_shutdown;
}
ls = GNUNET_NETWORK_socket_create (af,
SOCK_DGRAM,
@@ -399,17 +387,22 @@ run (void *cls,
GNUNET_a2s (local_sa,
local_len),
STRERROR (errno));
- global_ret = 1;
- GNUNET_SCHEDULER_shutdown ();
- return;
+ goto fail_and_shutdown;
}
rtask = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
ls,
&stun_read_task,
NULL);
}
-
+ GNUNET_free_non_null (remote_sa);
+ GNUNET_free_non_null (local_sa);
test_finished ();
+ return;
+ fail_and_shutdown:
+ global_ret = 1;
+ GNUNET_SCHEDULER_shutdown ();
+ GNUNET_free_non_null (remote_sa);
+ GNUNET_free_non_null (local_sa);
}
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [gnunet] 03/28: make sure 'err' is initialized on all error paths, (continued)
- [GNUnet-SVN] [gnunet] 03/28: make sure 'err' is initialized on all error paths, gnunet, 2017/03/10
- [GNUnet-SVN] [gnunet] 06/28: properly handle error on empty queue, gnunet, 2017/03/10
- [GNUnet-SVN] [gnunet] 04/28: handle case 'diff' is NULL - fixes NPE, gnunet, 2017/03/10
- [GNUnet-SVN] [gnunet] 02/28: make compiler happy, gnunet, 2017/03/10
- [GNUnet-SVN] [gnunet] 05/28: fix comment, gnunet, 2017/03/10
- [GNUnet-SVN] [gnunet] 07/28: fix memory leak, gnunet, 2017/03/10
- [GNUnet-SVN] [gnunet] 10/28: fix memory leak, gnunet, 2017/03/10
- [GNUnet-SVN] [gnunet] 20/28: fix out-of-bounds case in parser, gnunet, 2017/03/10
- [GNUnet-SVN] [gnunet] 15/28: add assertion to make static analysis happy, gnunet, 2017/03/10
- [GNUnet-SVN] [gnunet] 16/28: disambiguate enum type of value, gnunet, 2017/03/10
- [GNUnet-SVN] [gnunet] 09/28: fix memory leak,
gnunet <=
- [GNUnet-SVN] [gnunet] 17/28: add assertion to make static analysis happy, gnunet, 2017/03/10
- [GNUnet-SVN] [gnunet] 12/28: fix ICMP IPv4/IPv6 type conversion logic, gnunet, 2017/03/10
- [GNUnet-SVN] [gnunet] 22/28: check return value from dup2, gnunet, 2017/03/10
- [GNUnet-SVN] [gnunet] 14/28: fix double-free, gnunet, 2017/03/10
- [GNUnet-SVN] [gnunet] 11/28: fix double-free, gnunet, 2017/03/10
- [GNUnet-SVN] [gnunet] 18/28: fix integer overflow test to actually work, gnunet, 2017/03/10
- [GNUnet-SVN] [gnunet] 21/28: remove redundant condition in assertion, gnunet, 2017/03/10
- [GNUnet-SVN] [gnunet] 19/28: properly detect and handle parse error, gnunet, 2017/03/10
- [GNUnet-SVN] [gnunet] 13/28: prevent division by zero, gnunet, 2017/03/10
- [GNUnet-SVN] [gnunet] 23/28: check return value from GNUNET_program_run, gnunet, 2017/03/10