gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnunet] branch master updated: -fix leaks


From: gnunet
Subject: [gnunet] branch master updated: -fix leaks
Date: Sun, 19 May 2024 21:23:41 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new a44a6b8c8 -fix leaks
a44a6b8c8 is described below

commit a44a6b8c82c938660b617464c2336a49270d523e
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun May 19 21:23:37 2024 +0200

    -fix leaks
---
 src/lib/testing/test_testing_api.c         |  8 ++++++++
 src/lib/testing/testing_api_cmd_get_topo.c | 24 ++++++++++++++++++++----
 2 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/src/lib/testing/test_testing_api.c 
b/src/lib/testing/test_testing_api.c
index edf8187ec..f26960975 100644
--- a/src/lib/testing/test_testing_api.c
+++ b/src/lib/testing/test_testing_api.c
@@ -51,6 +51,12 @@ main (int argc,
                                 NULL),
     GNUNET_TESTING_cmd_end ()
   };
+  struct GNUNET_TESTING_Command netjail[] = {
+    GNUNET_TESTING_cmd_load_topology_from_string (
+      "load-topology",
+      ""),
+    GNUNET_TESTING_cmd_end ()
+  };
   struct GNUNET_TESTING_Command commands[] = {
     GNUNET_TESTING_cmd_batch ("batch",
                               batch),
@@ -108,6 +114,8 @@ main (int argc,
     GNUNET_TESTING_cmd_rewind_ip ("rewind",
                                   "wait-sleep",
                                   4),
+    GNUNET_TESTING_cmd_batch ("netjail",
+                              netjail),
     GNUNET_TESTING_cmd_end ()
   };
 
diff --git a/src/lib/testing/testing_api_cmd_get_topo.c 
b/src/lib/testing/testing_api_cmd_get_topo.c
index 4da06d5cb..486278489 100644
--- a/src/lib/testing/testing_api_cmd_get_topo.c
+++ b/src/lib/testing/testing_api_cmd_get_topo.c
@@ -50,6 +50,10 @@ struct TopologyState
    */
   const char *topology_string;
 
+  /**
+   * Same as @e topology_string, but set if we need
+   * to release the memory.
+   */
   char *topology_alloc;
 
   /**
@@ -67,6 +71,11 @@ cleanup (void *cls)
 {
   struct TopologyState *ts = cls;
 
+  if (NULL != ts->topology)
+  {
+    GNUNET_TESTING_free_topology (ts->topology);
+    ts->topology = NULL;
+  }
   GNUNET_free (ts->topology_alloc);
   GNUNET_free (ts);
 }
@@ -107,7 +116,7 @@ get_topo_string_from_file (const char *topology_data_file)
     LOG (GNUNET_ERROR_TYPE_ERROR,
          "Topology file %s not found\n",
          topology_data_file);
-    GNUNET_assert (0);
+    return NULL;
   }
   if (GNUNET_OK !=
       GNUNET_DISK_file_size (topology_data_file,
@@ -118,7 +127,7 @@ get_topo_string_from_file (const char *topology_data_file)
     LOG (GNUNET_ERROR_TYPE_ERROR,
          "Could not determine size of topology file %s\n",
          topology_data_file);
-    GNUNET_assert (0);
+    return NULL;
   }
   data = GNUNET_malloc_large (fs + 1);
   GNUNET_assert (NULL != data);
@@ -151,10 +160,16 @@ run (void *cls,
 
   if (NULL == ts->topology_string)
   {
-    ts->topology_alloc = get_topo_string_from_file (ts->file_name);
+    ts->topology_alloc
+      = get_topo_string_from_file (ts->file_name);
+    if (NULL == ts->topology_alloc)
+      GNUNET_TESTING_FAIL (is);
     ts->topology_string = ts->topology_alloc;
   }
-  ts->topology = GNUNET_TESTING_get_topo_from_string_ (ts->topology_string);
+  ts->topology
+    = GNUNET_TESTING_get_topo_from_string_ (ts->topology_string);
+  if (NULL == ts->topology)
+    GNUNET_TESTING_FAIL (is);
 }
 
 
@@ -185,6 +200,7 @@ GNUNET_TESTING_cmd_load_topology_from_string (
 {
   struct TopologyState *ts;
 
+  GNUNET_assert (NULL != topology_string);
   ts = GNUNET_new (struct TopologyState);
   ts->label = label;
   ts->topology_string = topology_string;

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]