View Issue Details

IDProjectCategoryView StatusLast Update
0007647GNUnethello librarypublic2023-06-01 20:26
Reporterulfvonbelow Assigned Toschanzen  
PrioritynormalSeveritytrivialReproducibilityalways
Status closedResolutionfixed 
Product VersionGit master 
Target Version0.19.4Fixed in Version0.19.4 
Summary0007647: Memory leak in test_hello-ng.c and test_hello-uri.c
Descriptionneither res nor the address returned from GNUNET_HELLO_extract_address are freed in the former, and b (the GNUNET_HELLO_Builder) isn't freed in the latter.
Steps To Reproduce./configure --enable-sanitizer
make
make install
make check
Additional InformationPatch attached.
Tagspatch
Attached Files
0001-HELLO-fix-memory-leaks-in-tests.patch (1,715 bytes)   
From 782ecfea5d7819a73ec1588ab511bbdb9a0bf961 Mon Sep 17 00:00:00 2001
From: ulfvonbelow <strilen@tilde.club>
Date: Sun, 29 Jan 2023 07:05:06 -0600
Subject: [PATCH] -HELLO: fix memory leaks in tests.

This allows us to use sanitizers to find bugs that matter.
---
 src/hello/test_hello-ng.c  | 8 ++++++--
 src/hello/test_hello-uri.c | 1 +
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/hello/test_hello-ng.c b/src/hello/test_hello-ng.c
index 4ace9439f..ef84e2425 100644
--- a/src/hello/test_hello-ng.c
+++ b/src/hello/test_hello-ng.c
@@ -31,6 +31,7 @@ main (int argc,
   struct GNUNET_PeerIdentity pid;
   struct GNUNET_TIME_Absolute t = GNUNET_TIME_absolute_get ();
   char *res;
+  char *address;
   size_t res_len;
   enum GNUNET_NetworkType nt;
 
@@ -47,10 +48,13 @@ main (int argc,
   GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
               "%s\n", res);
   GNUNET_assert (NULL !=
-                 GNUNET_HELLO_extract_address ((void**) res,
+                 (address =
+                  GNUNET_HELLO_extract_address ((void**) res,
                                                res_len,
                                                &pid,
                                                &nt,
-                                               &t));
+                                                &t)));
+  GNUNET_free (address);
+  GNUNET_free (res);
   return 0;
 }
diff --git a/src/hello/test_hello-uri.c b/src/hello/test_hello-uri.c
index 7e70d6763..01b6f2d8e 100644
--- a/src/hello/test_hello-uri.c
+++ b/src/hello/test_hello-uri.c
@@ -207,6 +207,7 @@ main (int argc,
              url);
     GNUNET_free (url);
   }
+  GNUNET_HELLO_builder_free (b);
 
   return 0;
 }
-- 
2.38.1

Activities

schanzen

2023-06-01 20:26

administrator   ~0020222

released some time ago

Issue History

Date Modified Username Field Change
2023-01-29 23:39 ulfvonbelow New Issue
2023-01-29 23:39 ulfvonbelow Tag Attached: patch
2023-01-29 23:39 ulfvonbelow File Added: 0001-HELLO-fix-memory-leaks-in-tests.patch
2023-02-06 05:56 schanzen Assigned To => schanzen
2023-02-06 05:56 schanzen Status new => resolved
2023-02-06 05:56 schanzen Resolution open => fixed
2023-02-06 05:56 schanzen Fixed in Version => 0.19.4
2023-02-06 06:19 schanzen Target Version => 0.19.4
2023-06-01 20:26 schanzen Note Added: 0020222
2023-06-01 20:26 schanzen Status resolved => closed