commit 36f1c9b91bcb1e5916b06aca632d189cc7c657ea
parent b5af1c99052f4c5053070cd5c6cc39b68eca2a20
Author: Christian Grothoff <christian@grothoff.org>
Date: Sun, 5 Jul 2026 23:14:37 +0200
fix leak of donau_keys
Diffstat:
1 file changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/lib/merchant_api_get-private-donau.c b/src/lib/merchant_api_get-private-donau.c
@@ -87,7 +87,6 @@ parse_donau_instances (const json_t *ia,
struct TALER_MERCHANT_GetPrivateDonauHandle *gpdh)
{
unsigned int instances_len = (unsigned int) json_array_size (ia);
- struct DONAU_Keys *donau_keys_ptr = NULL;
if ( (json_array_size (ia) != (size_t) instances_len) ||
(instances_len > MAX_DONAU_INSTANCES) )
@@ -98,9 +97,13 @@ parse_donau_instances (const json_t *ia,
{
struct TALER_MERCHANT_GetPrivateDonauDonauInstanceEntry instances[
GNUNET_NZL (instances_len)];
+ enum GNUNET_GenericReturnValue ret = GNUNET_OK;
size_t index;
json_t *value;
+ memset (instances,
+ 0,
+ sizeof (instances));
json_array_foreach (ia, index, value) {
struct TALER_MERCHANT_GetPrivateDonauDonauInstanceEntry *instance =
&instances[index];
@@ -135,34 +138,35 @@ parse_donau_instances (const json_t *ia,
NULL, NULL))
{
GNUNET_break_op (0);
- return GNUNET_SYSERR;
+ ret = GNUNET_SYSERR;
+ break;
}
/* Parse the Donau keys */
if (NULL != donau_keys_json)
{
- donau_keys_ptr = DONAU_keys_from_json (donau_keys_json);
- if (NULL == donau_keys_ptr)
+ instance->donau_keys = DONAU_keys_from_json (donau_keys_json);
+ if (NULL == instance->donau_keys)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to convert donau keys from JSON\n");
- return GNUNET_SYSERR;
+ ret = GNUNET_SYSERR;
+ break;
}
- instance->donau_keys = donau_keys_ptr;
}
}
- dgr->details.ok.donau_instances_length = instances_len;
- dgr->details.ok.donau_instances = instances;
- gpdh->cb (gpdh->cb_cls,
- dgr);
- gpdh->cb = NULL;
- if (NULL != donau_keys_ptr)
+ if (GNUNET_OK == ret)
{
- DONAU_keys_decref (donau_keys_ptr);
- donau_keys_ptr = NULL;
+ dgr->details.ok.donau_instances_length = instances_len;
+ dgr->details.ok.donau_instances = instances;
+ gpdh->cb (gpdh->cb_cls,
+ dgr);
+ gpdh->cb = NULL;
}
+ for (unsigned int i = 0; i < instances_len; i++)
+ DONAU_keys_decref (instances[i].donau_keys);
+ return ret;
}
- return GNUNET_OK;
}