gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] branch master updated: fix memory leaks


From: gnunet
Subject: [taler-anastasis] branch master updated: fix memory leaks
Date: Fri, 23 Oct 2020 17:21:57 +0200

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

dennis-neufeld pushed a commit to branch master
in repository anastasis.

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

commit f957ce39471d2e6bef735f36e8aec33ae1c6f341
Author: Dennis Neufeld <dennis.neufeld@students.bfh.ch>
AuthorDate: Fri Oct 23 17:21:53 2020 +0200

    fix memory leaks
---
 src/include/anastasis_service.h         |  1 -
 src/lib/anastasis.c                     | 30 ++++++++++++++++++++++++------
 src/lib/anastasis_api_policy_store.c    | 13 +++++++++++--
 src/lib/testing_api_cmd_policy_lookup.c |  1 +
 src/lib/testing_api_cmd_policy_store.c  |  1 -
 src/lib/testing_cmd_recover_secret.c    | 18 +++++++++++++++---
 src/lib/testing_cmd_secret_share.c      | 14 +++++++++++---
 7 files changed, 62 insertions(+), 16 deletions(-)

diff --git a/src/include/anastasis_service.h b/src/include/anastasis_service.h
index 55aedab..3336278 100644
--- a/src/include/anastasis_service.h
+++ b/src/include/anastasis_service.h
@@ -167,7 +167,6 @@ struct ANASTASIS_DownloadDetails
    * Number of bytes in @e backup.
    */
   size_t policy_size;
-
 };
 
 /**
diff --git a/src/lib/anastasis.c b/src/lib/anastasis.c
index 90789f1..a2d5b98 100644
--- a/src/lib/anastasis.c
+++ b/src/lib/anastasis.c
@@ -575,7 +575,6 @@ policy_lookup_cb (void *cls,
                                                       struct 
ANASTASIS_Challenge
                                                       *);
 
-
   for (unsigned int i = 0; i < r->ri->cs_len; i++)
   {
     cs[i] = GNUNET_new (struct ANASTASIS_Challenge);
@@ -791,6 +790,11 @@ ANASTASIS_recovery_abort (struct ANASTASIS_Recovery *r)
     ANASTASIS_policy_lookup_cancel (r->plo);
     r->plo = NULL;
   }
+  if (NULL != r->solved_challenges)
+  {
+    GNUNET_free (r->solved_challenges);
+    r->solved_challenges = NULL;
+  }
   if (NULL != r->encrypted_recovery_document)
   {
     GNUNET_free (r->encrypted_recovery_document);
@@ -1271,8 +1275,16 @@ ANASTASIS_policy_create (const struct ANASTASIS_Truth 
*truths[],
 void
 ANASTASIS_policy_destroy (struct ANASTASIS_Policy *p)
 {
-  GNUNET_free (p->truths);
-  p->truths = NULL;
+  if (NULL != p->nonces)
+  {
+    GNUNET_free (p->nonces);
+    p->nonces = NULL;
+  }
+  if (NULL != p->truths)
+  {
+    GNUNET_free (p->truths);
+    p->truths = NULL;
+  }
 
   GNUNET_free (p);
   p = NULL;
@@ -1359,7 +1371,7 @@ struct PolicyStoreState
   /**
    * Payment order ID we got back, if any. Otherwise NULL.
    */
-  const char *payment_order_id;
+  char *payment_order_id;
 
   /**
    * Payment order ID we are to provide in the request, may be NULL.
@@ -1443,6 +1455,11 @@ policy_store_cleanup (void *cls)
     GNUNET_free (pss->recovery_data);
     pss->recovery_data = NULL;
   }
+  if (NULL != pss->payment_order_id)
+  {
+    GNUNET_free (pss->payment_order_id);
+    pss->payment_order_id = NULL;
+  }
   GNUNET_free (pss);
   pss = NULL;
 }
@@ -1501,7 +1518,8 @@ policy_store_cb (void *cls,
              the above token must appear in the payment request!
 
              So if you hit this, you might just want to modify
-             the code here to handle this better! */return;
+             the code here to handle this better! */
+          return;
         }
         pss->payment_order_id = GNUNET_strdup (&m[strlen ("/-/-/")]);
         GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -1891,6 +1909,7 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
     "escrow_methods", esc_methods,
     "core_secret", GNUNET_JSON_from_data (encrypted_core_secret,
                                           core_secret_size));
+  GNUNET_free (encrypted_core_secret);
   GNUNET_assert (NULL != recovery_document);
 
   // FIXME COMPRESSION
@@ -1944,7 +1963,6 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
                                               ss->pss[l]);
     GNUNET_assert (NULL != ss->pss[l]->pso);
   }
-
   // FIXME: clean up PSS, TRUTHS etc. !!!
   // SETUP SHARE RESULT CALLBACK
   return ss;
diff --git a/src/lib/anastasis_api_policy_store.c 
b/src/lib/anastasis_api_policy_store.c
index 1169b5c..61903d9 100644
--- a/src/lib/anastasis_api_policy_store.c
+++ b/src/lib/anastasis_api_policy_store.c
@@ -90,9 +90,18 @@ ANASTASIS_policy_store_cancel (struct
     GNUNET_CURL_job_cancel (pso->job);
     pso->job = NULL;
   }
-  GNUNET_free (pso->pay_uri);
-  GNUNET_free (pso->url);
+  if (NULL != pso->pay_uri)
+  {
+    GNUNET_free (pso->pay_uri);
+    pso->pay_uri = NULL;
+  }
+  if (NULL != pso->url)
+  {
+    GNUNET_free (pso->url);
+    pso->url = NULL;
+  }
   GNUNET_free (pso);
+  pso = NULL;
 }
 
 
diff --git a/src/lib/testing_api_cmd_policy_lookup.c 
b/src/lib/testing_api_cmd_policy_lookup.c
index 1b3f1dc..346c323 100644
--- a/src/lib/testing_api_cmd_policy_lookup.c
+++ b/src/lib/testing_api_cmd_policy_lookup.c
@@ -72,6 +72,7 @@ struct PolicyLookupState
   struct ANASTASIS_PolicyLookupOperation *plo;
 };
 
+
 /**
  * Function called with the results of a #ANASTASIS_lookup().
  *
diff --git a/src/lib/testing_api_cmd_policy_store.c 
b/src/lib/testing_api_cmd_policy_store.c
index d573530..3750d20 100644
--- a/src/lib/testing_api_cmd_policy_store.c
+++ b/src/lib/testing_api_cmd_policy_store.c
@@ -424,7 +424,6 @@ policy_store_cleanup (void *cls,
     ANASTASIS_policy_store_cancel (pss->pso);
     pss->pso = NULL;
   }
-
   GNUNET_free (pss->payment_order_id);
   GNUNET_free (pss);
 }
diff --git a/src/lib/testing_cmd_recover_secret.c 
b/src/lib/testing_cmd_recover_secret.c
index e4794c7..66a44ad 100644
--- a/src/lib/testing_cmd_recover_secret.c
+++ b/src/lib/testing_cmd_recover_secret.c
@@ -56,44 +56,51 @@ struct RecoverSecretState
    * Reference to download command we expect to lookup.
    */
   const char *download_reference;
+
   /**
    * Reference to download command we expect to lookup.
    */
   const char *core_secret_reference;
+
   /**
    * Options for how we are supposed to do the download.
    */
   enum ANASTASIS_TESTING_RecoverSecretOption rsopt;
+
   /**
    * Identification data from the user
    */
   json_t *id_data;
+
   /**
    * version of the recovery document
    */
   unsigned int version;
+
   /**
    * Salt to be used to derive the id
    */
   struct ANASTASIS_CRYPTO_PowSalt *salt;
+
   /**
    * Recovery information from the lookup
    */
-  const struct ANASTASIS_RecoveryInformation *ri;
+  struct ANASTASIS_RecoveryInformation *ri;
+
   /**
    * Coresecret to check if decryption worked
    */
   const void *core_secret;
+};
 
 
-};
 static void
 policy_lookup_cb (void *cls,
                   const struct ANASTASIS_RecoveryInformation *ri,
                   const enum TALER_ErrorCode ec)
 {
   struct RecoverSecretState *rss = cls;
-  rss->ri = ri;
+  rss->ri = (struct ANASTASIS_RecoveryInformation *) ri;
   if (NULL == ri)
   {
     GNUNET_break (0);
@@ -213,7 +220,12 @@ recover_secret_cleanup (void *cls,
   // FIXME: Cleanup logic
   struct RecoverSecretState *rss = cls;
   ANASTASIS_recovery_abort (rss->recovery);
+  json_decref (rss->id_data);
+  GNUNET_free (rss->ri->cs);
+  GNUNET_free (rss->ri->dps);
+  GNUNET_free (rss->ri);
   GNUNET_free (rss);
+  rss = NULL;
 }
 
 
diff --git a/src/lib/testing_cmd_secret_share.c 
b/src/lib/testing_cmd_secret_share.c
index ac8bca1..81bbc38 100644
--- a/src/lib/testing_cmd_secret_share.c
+++ b/src/lib/testing_cmd_secret_share.c
@@ -111,7 +111,6 @@ struct SecretShareState
    * Payment order ID we got back, if any. Otherwise NULL.
    */
   const char *payment_order_id;
-
 };
 
 
@@ -389,8 +388,17 @@ secret_share_cleanup (void *cls,
 {
   struct SecretShareState *sss = cls;
 
-  GNUNET_free (sss->cmd_label_array);
-  sss->cmd_label_array = NULL;
+  if (NULL != sss->cmd_label_array)
+  {
+    GNUNET_free (sss->cmd_label_array);
+    sss->cmd_label_array = NULL;
+  }
+  if (NULL != sss->sso)
+  {
+    GNUNET_free (sss->sso);
+    sss->sso = NULL;
+  }
+  json_decref ((json_t *) sss->id_data);
   GNUNET_free (sss);
   sss = NULL;
 }

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