View Issue Details

IDProjectCategoryView StatusLast Update
0008789GNUnettransport servicepublic2024-06-08 12:03
Reporterulfvonbelow Assigned Toschanzen  
PrioritynormalSeveritytrivialReproducibilityalways
Status closedResolutionfixed 
Platformx86-64OSGuix SystemOS Versiona1d711c92e
Product Version0.21.1 
Fixed in Version0.21.2 
Summary0008789: memory leaks in transport-testing-communicator.c
DescriptionThe various fields of struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue aren't freed when it is.
Steps To Reproduce1. ./configure --enable-sanitizer ; make ; make check
2. Observe memory leak in anything that uses transport-testing-communicator
Additional InformationPatch attached.
TagsNo tags attached.
Attached Files
0001-transport-fix-memory-leaks-in-transport-testing-comm.patch (2,459 bytes)   
From a3183dd7cfd13b75a554e92856bcffade570b19d Mon Sep 17 00:00:00 2001
From: ulfvonbelow <striness@tilde.club>
Date: Thu, 2 May 2024 19:25:16 -0500
Subject: [PATCH] transport: fix memory leaks in
 transport-testing-communicator.c.

---
 .../transport/transport-testing-communicator.c       | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/service/transport/transport-testing-communicator.c b/src/service/transport/transport-testing-communicator.c
index 7d8abbe1e..9ee70fe7b 100644
--- a/src/service/transport/transport-testing-communicator.c
+++ b/src/service/transport/transport-testing-communicator.c
@@ -186,6 +186,7 @@ handle_communicator_available (
     return; /* receive-only communicator */
   }
   tc_h->c_characteristics = ntohl (msg->cc);
+  GNUNET_free (tc_h->c_addr_prefix);
   tc_h->c_addr_prefix = GNUNET_strdup ((const char *) &msg[1]);
   if (NULL != tc_h->communicator_available_cb)
   {
@@ -320,6 +321,7 @@ handle_add_address (void *cls,
   if (0 == size)
     return; /* receive-only communicator */
   LOG (GNUNET_ERROR_TYPE_DEBUG, "received add address cb %u\n", size);
+  GNUNET_free (tc_h->c_address);
   tc_h->c_address = GNUNET_strdup ((const char *) &msg[1]);
   if (NULL != tc_h->add_address_cb)
   {
@@ -852,6 +854,7 @@ communicator_start (
                                             "-c",
                                             tc_h->cfg_filename,
                                             NULL);
+  GNUNET_free (loprefix);
   if (NULL == tc_h->c_proc)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to start communicator!");
@@ -1093,6 +1096,7 @@ void
 GNUNET_TRANSPORT_TESTING_transport_communicator_service_stop (
   struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h)
 {
+  struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *queue;
   shutdown_communicator (tc_h->c_proc);
   shutdown_service (tc_h->sh);
   shutdown_nat (tc_h->nat_proc);
@@ -1100,6 +1104,14 @@ GNUNET_TRANSPORT_TESTING_transport_communicator_service_stop (
   shutdown_peerstore (tc_h->ps_proc);
   shutdown_statistics (tc_h->stat_proc);
   GNUNET_CONFIGURATION_destroy (tc_h->cfg);
+  while (NULL != (queue = tc_h->queue_head))
+  {
+    GNUNET_CONTAINER_DLL_remove (tc_h->queue_head, tc_h->queue_tail, queue);
+    GNUNET_free (queue);
+  }
+  GNUNET_free (tc_h->c_address);
+  GNUNET_free (tc_h->cfg_filename);
+  GNUNET_free (tc_h->c_addr_prefix);
   GNUNET_free (tc_h);
 }
 
-- 
2.41.0

Activities

schanzen

2024-05-05 14:01

administrator   ~0022342

Applied in 730000a9ccce29d3c5c7c7af50dfbd6b1fdeac7a. Thanks.

schanzen

2024-06-08 12:03

administrator   ~0022557

0.21.2 released

Issue History

Date Modified Username Field Change
2024-05-03 03:43 ulfvonbelow New Issue
2024-05-03 03:43 ulfvonbelow File Added: 0001-transport-fix-memory-leaks-in-transport-testing-comm.patch
2024-05-05 14:01 schanzen Assigned To => schanzen
2024-05-05 14:01 schanzen Status new => resolved
2024-05-05 14:01 schanzen Resolution open => fixed
2024-05-05 14:01 schanzen Fixed in Version => 0.21.2
2024-05-05 14:01 schanzen Note Added: 0022342
2024-06-08 12:03 schanzen Note Added: 0022557
2024-06-08 12:03 schanzen Status resolved => closed