exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

commit 1941102d3e43d17cce387273ed09ea24c3c85521
parent bba9ba6f0ec01a71ac15ac9c6b85fe1d9c500f99
Author: Christian Grothoff <grothoff@gnunet.org>
Date:   Fri, 10 Jul 2026 22:37:19 +0200

fix leaks

Diffstat:
Msrc/json/json.c | 17+++++++++--------
Msrc/json/json_helper.c | 31+++++++++++++++++++++++++++++++
Msrc/util/config.c | 5++---
3 files changed, 42 insertions(+), 11 deletions(-)

diff --git a/src/json/json.c b/src/json/json.c @@ -185,17 +185,18 @@ forget (const json_t *in, const char *key; json_t *value; json_t *fg; - json_t *rx; + json_t *rx = NULL; + json_t *rx_orig; fg = json_object_get (in, "$forgettable"); - rx = json_object_get (in, - "$forgotten"); - if (NULL != rx) + rx_orig = json_object_get (in, + "$forgotten"); + if (NULL != rx_orig) { - rx = json_deep_copy (rx); /* should be shallow - by structure, but - deep copy is safer */ + rx = json_deep_copy (rx_orig); /* should be shallow + by structure, but + deep copy is safer */ if (NULL == rx) { GNUNET_break (0); @@ -215,7 +216,7 @@ forget (const json_t *in, if (fg == value) continue; /* skip! */ - if (rx == value) + if (rx_orig == value) continue; /* skip! */ if ( (NULL != rx) && (NULL != diff --git a/src/json/json_helper.c b/src/json/json_helper.c @@ -2285,6 +2285,11 @@ parse_array_of_blinded_denom_sigs (void *cls, if (GNUNET_OK != ret) { GNUNET_break_op (0); + for (size_t i = 0; i < idx; i++) + { + TALER_blinded_denom_sig_free (&sigs[i]); + sigs[i].blinded_sig = NULL; + } return GNUNET_SYSERR; } ptr++; @@ -2294,6 +2299,31 @@ parse_array_of_blinded_denom_sigs (void *cls, } +/** + * Cleanup data left from parsing an array of blinded signatures. + * + * @param cls pointer to a size_t with the length of the array + * @param[out] spec where to free the data + */ +static void +cleaner_array_of_blinded_denom_sigs ( + void *cls, + struct GNUNET_JSON_Specification *spec) +{ + struct TALER_BlindedDenominationSignature *sigs = spec->ptr; + size_t *num_entries = cls; + + for (size_t i = 0; i < *num_entries; i++) + { + if (NULL != sigs[i].blinded_sig) + { + TALER_blinded_denom_sig_free (&sigs[i]); + sigs[i].blinded_sig = NULL; + } + } +} + + struct GNUNET_JSON_Specification TALER_JSON_spec_array_of_blinded_denom_sigs ( const char *field, @@ -2304,6 +2334,7 @@ TALER_JSON_spec_array_of_blinded_denom_sigs ( .parser = &parse_array_of_blinded_denom_sigs, .ptr = entries, .field = field, + .cleaner = &cleaner_array_of_blinded_denom_sigs, .cls = (void *) num_entries, }; diff --git a/src/util/config.c b/src/util/config.c @@ -505,9 +505,8 @@ TALER_CONFIG_parse_currencies (const struct GNUNET_CONFIGURATION_Handle *cfg, &cpc); if (cpc.failure) { - GNUNET_array_grow (cpc.cspecs, - cpc.len_cspecs, - 0); + TALER_CONFIG_free_currencies (cpc.num_currencies, + cpc.cspecs); return GNUNET_SYSERR; } /* Make sure that there is some sane fallback for the main currency */