gnunet-svn
[Top][All Lists]
Advanced

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

[taler-exchange] branch master updated: -fix misc memory leaks


From: gnunet
Subject: [taler-exchange] branch master updated: -fix misc memory leaks
Date: Sun, 29 Oct 2023 21:29:35 +0100

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

grothoff pushed a commit to branch master
in repository exchange.

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

commit c6c149714c9b39844d6dee2b5339907cca5bed3c
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun Oct 29 21:26:02 2023 +0100

    -fix misc memory leaks
---
 src/exchange/taler-exchange-httpd_extensions.c   | 12 ++++++---
 src/exchange/taler-exchange-httpd_keys.c         | 34 ++++++++----------------
 src/extensions/age_restriction/age_restriction.c | 11 ++++----
 src/json/json_helper.c                           | 21 ++++++++++++++-
 4 files changed, 45 insertions(+), 33 deletions(-)

diff --git a/src/exchange/taler-exchange-httpd_extensions.c 
b/src/exchange/taler-exchange-httpd_extensions.c
index 68cc2da5..1ee573b0 100644
--- a/src/exchange/taler-exchange-httpd_extensions.c
+++ b/src/exchange/taler-exchange-httpd_extensions.c
@@ -1,6 +1,6 @@
 /*
   This file is part of TALER
-  Copyright (C) 2021 Taler Systems SA
+  Copyright (C) 2021, 2023 Taler Systems SA
 
   TALER is free software; you can redistribute it and/or modify it under the
   terms of the GNU Affero General Public License as published by the Free 
Software
@@ -208,16 +208,20 @@ TEH_extensions_init ()
   {
     const struct TALER_Extension *ext = it->extension;
     uint32_t typ = htonl (ext->type);
-    char *manifest = json_dumps (ext->manifest (ext), JSON_COMPACT);
+    json_t *jmani;
+    char *manifest;
 
+    jmani = ext->manifest (ext);
+    manifest = json_dumps (jmani,
+                           JSON_COMPACT);
+    json_decref (jmani);
     TEH_plugin->set_extension_manifest (TEH_plugin->cls,
                                         ext->name,
                                         manifest);
-
+    free (manifest);
     extension_update_event_cb (NULL,
                                &typ,
                                sizeof(typ));
-    free (manifest);
   }
 
   return GNUNET_OK;
diff --git a/src/exchange/taler-exchange-httpd_keys.c 
b/src/exchange/taler-exchange-httpd_keys.c
index ec49607c..913cd734 100644
--- a/src/exchange/taler-exchange-httpd_keys.c
+++ b/src/exchange/taler-exchange-httpd_keys.c
@@ -736,13 +736,6 @@ struct AddContext
    */
   json_t *a;
 
-  /**
-   * Context we hash "everything" we add into. This is used
-   * to compute the etag. Technically, we only hash the
-   * master_sigs, as they imply the rest.
-   */
-  struct GNUNET_HashContext *hc;
-
   /**
    * Set to the maximum end-date seen.
    */
@@ -783,9 +776,6 @@ add_wire_fee (void *cls,
                 "Database has wire fee with invalid signature. Skipping entry. 
Did the exchange offline public key change?\n");
     return;
   }
-  GNUNET_CRYPTO_hash_context_read (ac->hc,
-                                   master_sig,
-                                   sizeof (*master_sig));
   ac->max_seen = GNUNET_TIME_absolute_max (ac->max_seen,
                                            end_date.abs_time);
   wfs = GNUNET_new (struct WireFeeSet);
@@ -830,7 +820,6 @@ build_wire_state (void)
   uint64_t wg = wire_generation; /* must be obtained FIRST */
   enum GNUNET_DB_QueryStatus qs;
   struct WireStateHandle *wsh;
-  struct GNUNET_HashContext *hc;
   json_t *wads;
 
   wsh = GNUNET_new (struct WireStateHandle);
@@ -853,12 +842,14 @@ build_wire_state (void)
   wire_fee_object = json_object ();
   GNUNET_assert (NULL != wire_fee_object);
   wsh->cache_expiration = GNUNET_TIME_UNIT_FOREVER_ABS;
-  hc = GNUNET_CRYPTO_hash_context_start ();
   {
     json_t *account;
     size_t index;
 
-    json_array_foreach (wire_accounts_array, index, account) {
+    json_array_foreach (wire_accounts_array,
+                        index,
+                        account)
+    {
       char *wire_method;
       const char *payto_uri = json_string_value (json_object_get (account,
                                                                   
"payto_uri"));
@@ -873,7 +864,6 @@ build_wire_state (void)
         wsh->ready = false;
         json_decref (wire_accounts_array);
         json_decref (wire_fee_object);
-        GNUNET_CRYPTO_hash_context_abort (hc);
         return wsh;
       }
       if (NULL == json_object_get (wire_fee_object,
@@ -882,8 +872,7 @@ build_wire_state (void)
         struct AddContext ac = {
           .wire_method = wire_method,
           .wsh = wsh,
-          .a = json_array (),
-          .hc = hc
+          .a = json_array ()
         };
 
         GNUNET_assert (NULL != ac.a);
@@ -899,7 +888,6 @@ build_wire_state (void)
           json_decref (wire_accounts_array);
           GNUNET_free (wire_method);
           wsh->ready = false;
-          GNUNET_CRYPTO_hash_context_abort (hc);
           return wsh;
         }
         if (0 != json_array_size (ac.a))
@@ -924,12 +912,12 @@ build_wire_state (void)
   wads = json_array (); /* #7271 */
   GNUNET_assert (NULL != wads);
   wsh->json_reply = GNUNET_JSON_PACK (
-    GNUNET_JSON_pack_array_incref ("accounts",
-                                   wire_accounts_array),
-    GNUNET_JSON_pack_array_incref ("wads",
-                                   wads),
-    GNUNET_JSON_pack_object_incref ("fees",
-                                    wire_fee_object));
+    GNUNET_JSON_pack_array_steal ("accounts",
+                                  wire_accounts_array),
+    GNUNET_JSON_pack_array_steal ("wads",
+                                  wads),
+    GNUNET_JSON_pack_object_steal ("fees",
+                                   wire_fee_object));
   wsh->ready = true;
   return wsh;
 }
diff --git a/src/extensions/age_restriction/age_restriction.c 
b/src/extensions/age_restriction/age_restriction.c
index 644a4ac6..08b598d5 100644
--- a/src/extensions/age_restriction/age_restriction.c
+++ b/src/extensions/age_restriction/age_restriction.c
@@ -127,12 +127,13 @@ age_restriction_manifest (
     GNUNET_JSON_pack_string ("age_groups",
                              TALER_age_mask_to_string (&AR_config.mask))
     );
-
-
   return GNUNET_JSON_PACK (
-    GNUNET_JSON_pack_bool ("critical", ext->critical),
-    GNUNET_JSON_pack_string ("version", ext->version),
-    GNUNET_JSON_pack_object_steal ("config", conf)
+    GNUNET_JSON_pack_bool ("critical",
+                           ext->critical),
+    GNUNET_JSON_pack_string ("version",
+                             ext->version),
+    GNUNET_JSON_pack_object_steal ("config",
+                                   conf)
     );
 }
 
diff --git a/src/json/json_helper.c b/src/json/json_helper.c
index 2cc63e17..71291a9e 100644
--- a/src/json/json_helper.c
+++ b/src/json/json_helper.c
@@ -1,6 +1,6 @@
 /*
   This file is part of TALER
-  Copyright (C) 2014-2021 Taler Systems SA
+  Copyright (C) 2014-2023 Taler Systems SA
 
   TALER is free software; you can redistribute it and/or modify it under the
   terms of the GNU General Public License as published by the Free Software
@@ -1238,6 +1238,24 @@ parse_exchange_withdraw_values (void *cls,
 }
 
 
+/**
+ * Cleanup data left from parsing withdraw values
+ *
+ * @param cls closure, NULL
+ * @param[out] spec where to free the data
+ */
+static void
+clean_exchange_withdraw_values (
+  void *cls,
+  struct GNUNET_JSON_Specification *spec)
+{
+  struct TALER_ExchangeWithdrawValues *ewv = spec->ptr;
+
+  (void) cls;
+  TALER_denom_ewv_free (ewv);
+}
+
+
 struct GNUNET_JSON_Specification
 TALER_JSON_spec_exchange_withdraw_values (
   const char *field,
@@ -1245,6 +1263,7 @@ TALER_JSON_spec_exchange_withdraw_values (
 {
   struct GNUNET_JSON_Specification ret = {
     .parser = &parse_exchange_withdraw_values,
+    .cleaner = &clean_exchange_withdraw_values,
     .field = field,
     .ptr = ewv
   };

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