summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2023-10-29 21:26:02 +0100
committerChristian Grothoff <christian@grothoff.org>2023-10-29 21:26:02 +0100
commitc6c149714c9b39844d6dee2b5339907cca5bed3c (patch)
tree2b9f63ddf6b810a0565e4da4bffad15772aad49a
parent3784541b6c7e178546e91d9cb6579d8643989f59 (diff)
downloadexchange-c6c149714c9b39844d6dee2b5339907cca5bed3c.tar.gz
exchange-c6c149714c9b39844d6dee2b5339907cca5bed3c.tar.bz2
exchange-c6c149714c9b39844d6dee2b5339907cca5bed3c.zip
-fix misc memory leaks
-rw-r--r--src/exchange/taler-exchange-httpd_extensions.c12
-rw-r--r--src/exchange/taler-exchange-httpd_keys.c34
-rw-r--r--src/extensions/age_restriction/age_restriction.c11
-rw-r--r--src/json/json_helper.c21
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 68cc2da55..1ee573b0f 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 ec49607cf..913cd7343 100644
--- a/src/exchange/taler-exchange-httpd_keys.c
+++ b/src/exchange/taler-exchange-httpd_keys.c
@@ -737,13 +737,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.
*/
struct GNUNET_TIME_Absolute max_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 644a4ac6a..08b598d50 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 2cc63e170..71291a9e5 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
};