gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet] branch master updated: peerstore: fix memory leaks in peerstore


From: gnunet
Subject: [gnunet] branch master updated: peerstore: fix memory leaks in peerstore_api.c.
Date: Mon, 06 May 2024 09:24:27 +0200

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

martin-schanzenbach pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new 0f1aa84f6 peerstore: fix memory leaks in peerstore_api.c.
0f1aa84f6 is described below

commit 0f1aa84f60d360a3e3aac17eb8fdb269bd80e866
Author: ulfvonbelow <striness@tilde.club>
AuthorDate: Thu May 2 19:31:25 2024 -0500

    peerstore: fix memory leaks in peerstore_api.c.
    
    Signed-off-by: Martin Schanzenbach <schanzen@gnunet.org>
---
 src/service/peerstore/peerstore_api.c | 34 +++++++++++++++++++++++-----------
 1 file changed, 23 insertions(+), 11 deletions(-)

diff --git a/src/service/peerstore/peerstore_api.c 
b/src/service/peerstore/peerstore_api.c
index 19cb1213e..898d58a2c 100644
--- a/src/service/peerstore/peerstore_api.c
+++ b/src/service/peerstore/peerstore_api.c
@@ -446,6 +446,7 @@ GNUNET_PEERSTORE_disconnect (struct GNUNET_PEERSTORE_Handle 
*h)
 {
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Disconnect initiated from client.\n");
   disconnect (h);
+  GNUNET_free (h);
 }
 
 
@@ -453,6 +454,15 @@ GNUNET_PEERSTORE_disconnect (struct 
GNUNET_PEERSTORE_Handle *h)
 /*******************            STORE FUNCTIONS           
*********************/
 
/******************************************************************************/
 
+static void
+destroy_storecontext(struct GNUNET_PEERSTORE_StoreContext *sc)
+{
+  GNUNET_CONTAINER_DLL_remove (sc->h->store_head, sc->h->store_tail, sc);
+  GNUNET_free (sc->sub_system);
+  GNUNET_free (sc->value);
+  GNUNET_free (sc->key);
+  GNUNET_free (sc);
+}
 
 /**
  * Cancel a store request
@@ -465,11 +475,7 @@ GNUNET_PEERSTORE_store_cancel (struct 
GNUNET_PEERSTORE_StoreContext *sc)
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "store cancel with sc %p \n",
        sc);
-  GNUNET_CONTAINER_DLL_remove (sc->h->store_head, sc->h->store_tail, sc);
-  GNUNET_free (sc->sub_system);
-  GNUNET_free (sc->value);
-  GNUNET_free (sc->key);
-  GNUNET_free (sc);
+  destroy_storecontext(sc);
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "store cancel with sc %p is null\n",
        sc);
@@ -576,7 +582,7 @@ handle_store_result (void *cls, const struct 
PeerstoreResultMessage *msg)
   }
   if (NULL != sc->cont)
     sc->cont (sc->cont_cls, ntohl (msg->result));
-  GNUNET_CONTAINER_DLL_remove (h->store_head, h->store_tail, sc);
+  destroy_storecontext (sc);
 }
 
 
@@ -584,6 +590,15 @@ handle_store_result (void *cls, const struct 
PeerstoreResultMessage *msg)
 /*******************           ITERATE FUNCTIONS          
*********************/
 
/******************************************************************************/
 
+static void
+destroy_iteratecontext(struct GNUNET_PEERSTORE_IterateContext *ic)
+{
+  GNUNET_CONTAINER_DLL_remove (ic->h->iterate_head, ic->h->iterate_tail, ic);
+  GNUNET_free (ic->sub_system);
+  GNUNET_free (ic->key);
+  GNUNET_free (ic);
+}
+
 
 /**
  * When a response for iterate request is received
@@ -609,7 +624,7 @@ handle_iterate_end (void *cls, const struct 
PeerstoreResultMessage *msg)
   if (NULL != ic->callback)
     ic->callback (ic->callback_cls, NULL, NULL);
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up iteration with rid %u\n", 
ic->rid);
-  GNUNET_CONTAINER_DLL_remove (h->iterate_head, h->iterate_tail, ic);
+  destroy_iteratecontext (ic);
 }
 
 
@@ -719,10 +734,7 @@ GNUNET_PEERSTORE_iteration_stop (struct 
GNUNET_PEERSTORE_IterateContext *ic)
     if (NULL != ic->h->mq)
       GNUNET_MQ_send (ic->h->mq, ev);
   }
-  GNUNET_CONTAINER_DLL_remove (ic->h->iterate_head, ic->h->iterate_tail, ic);
-  GNUNET_free (ic->sub_system);
-  GNUNET_free (ic->key);
-  GNUNET_free (ic);
+  destroy_iteratecontext (ic);
 }
 
 

-- 
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]