commit 837966947ee91694d3364b8fbadc05b93619314b
parent 8add8dc8a9948998204df357c6a084957bf2477e
Author: Christian Grothoff <christian@grothoff.org>
Date: Sun, 26 Oct 2025 02:18:43 +0200
fix leaks (#10505)
Diffstat:
4 files changed, 35 insertions(+), 5 deletions(-)
diff --git a/src/donau/donau-httpd_batch-issue.c b/src/donau/donau-httpd_batch-issue.c
@@ -107,7 +107,7 @@ signatures_to_json (const size_t num_sig,
struct DONAU_BlindedDonationUnitSignature *signature = &signatures[i];
GNUNET_assert (
- 0 == json_array_append (
+ 0 == json_array_append_new (
j_signatures,
GNUNET_JSON_PACK (
DONAU_JSON_pack_blinded_donation_unit_sig ("blinded_signature",
@@ -253,6 +253,8 @@ DH_handler_issue_receipts_post (struct DH_RequestContext *rc,
GNUNET_break_op (0);
free_bkps (num_bkps,
bkps);
+ GNUNET_free (charity_meta.charity_name);
+ GNUNET_free (charity_meta.charity_url);
return TALER_MHD_reply_with_error (
rc->connection,
MHD_HTTP_FORBIDDEN,
@@ -260,6 +262,8 @@ DH_handler_issue_receipts_post (struct DH_RequestContext *rc,
"charity_sig");
}
+ GNUNET_free (charity_meta.charity_name);
+ GNUNET_free (charity_meta.charity_url);
{
/* request already made? -> idempotent */
enum GNUNET_DB_QueryStatus qs_check_receipts;
@@ -281,6 +285,7 @@ DH_handler_issue_receipts_post (struct DH_RequestContext *rc,
{
case GNUNET_CRYPTO_BSA_INVALID:
GNUNET_assert (0);
+ break;
case GNUNET_CRYPTO_BSA_CS:
GNUNET_CRYPTO_hash_context_read (
hc,
diff --git a/src/donau/donau-httpd_batch-submit.c b/src/donau/donau-httpd_batch-submit.c
@@ -39,6 +39,7 @@ struct InsertReceiptContext
{
struct DONAU_HashDonorTaxId h_donor_tax_id;
struct DONAU_DonationReceipt *donation_receipts;
+ size_t num_dr;
uint64_t donation_year;
};
@@ -78,6 +79,21 @@ parse_json_dr (struct DONAU_DonationReceipt *dr,
}
+/**
+ * Free data in @a irc, but not @a irc itself
+ *
+ * @param[in,out] irc data structure to clean up
+ */
+static void
+free_irc (struct InsertReceiptContext *irc)
+{
+ for (size_t i = 0; i<irc->num_dr; i++)
+ GNUNET_CRYPTO_unblinded_sig_decref (irc->donation_receipts[i].
+ donation_unit_sig.unblinded_sig);
+ GNUNET_free (irc->donation_receipts);
+}
+
+
MHD_RESULT
DH_handler_submit_receipts_post (struct DH_RequestContext *rc,
const json_t *root,
@@ -127,6 +143,7 @@ DH_handler_submit_receipts_post (struct DH_RequestContext *rc,
json_t *dr_obj;
size_t index;
+ irc.num_dr = num_dr;
irc.donation_receipts = GNUNET_new_array (num_dr,
struct DONAU_DonationReceipt);
@@ -135,9 +152,11 @@ DH_handler_submit_receipts_post (struct DH_RequestContext *rc,
dr_obj)
{
if (GNUNET_SYSERR ==
- parse_json_dr (&irc.donation_receipts[index], dr_obj))
+ parse_json_dr (&irc.donation_receipts[index],
+ dr_obj))
{
GNUNET_break_op (0);
+ free_irc (&irc);
return TALER_MHD_reply_with_error (rc->connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_GENERIC_PARAMETER_MALFORMED,
@@ -160,6 +179,7 @@ DH_handler_submit_receipts_post (struct DH_RequestContext *rc,
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Donation receipt nonce is not unique!\n");
+ free_irc (&irc);
return TALER_MHD_reply_with_error (rc->connection,
MHD_HTTP_CONFLICT,
TALER_EC_DONAU_DONOR_IDENTIFIER_NONCE_REUSE,
@@ -172,6 +192,7 @@ DH_handler_submit_receipts_post (struct DH_RequestContext *rc,
&irc.donation_receipts[i].h_donation_unit_pub)))
{
GNUNET_break_op (0);
+ free_irc (&irc);
return TALER_MHD_reply_with_error (rc->connection,
MHD_HTTP_NOT_FOUND,
TALER_EC_DONAU_GENERIC_DONATION_UNIT_UNKNOWN,
@@ -191,6 +212,7 @@ DH_handler_submit_receipts_post (struct DH_RequestContext *rc,
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Donation receipt signature invalid!\n");
+ free_irc (&irc);
return TALER_MHD_reply_with_error (rc->connection,
MHD_HTTP_FORBIDDEN,
TALER_EC_DONAU_DONATION_RECEIPT_SIGNATURE_INVALID,
@@ -208,6 +230,7 @@ DH_handler_submit_receipts_post (struct DH_RequestContext *rc,
num_dr,
irc.donation_receipts,
irc.donation_year);
+ free_irc (&irc);
if (qs < 0)
{
GNUNET_break (0);
diff --git a/src/donaudb/pg_insert_submitted_receipts.c b/src/donaudb/pg_insert_submitted_receipts.c
@@ -54,7 +54,7 @@ DH_PG_insert_submitted_receipts (
GNUNET_PQ_query_param_uint64 (&donation_year),
GNUNET_PQ_query_param_end
};
- bool *conflicted;
+ bool *conflicted = NULL;
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_array_bool (pg->conn,
"conflicted",
@@ -96,6 +96,7 @@ DH_PG_insert_submitted_receipts (
i);
}
}
+ GNUNET_free (conflicted);
GNUNET_PQ_cleanup_result (rs);
return qs;
}
diff --git a/src/pq/pq_query_helper.c b/src/pq/pq_query_helper.c
@@ -788,8 +788,9 @@ array_cleanup (void *cls,
GNUNET_assert (NULL != info->num);
for (size_t i = 0; i < *info->num; i++)
- GNUNET_free (du_sigs[i].blinded_sig);
- GNUNET_free (cls);
+ if (NULL != du_sigs[i].blinded_sig)
+ GNUNET_CRYPTO_blinded_sig_decref (du_sigs[i].blinded_sig);
+ GNUNET_free (info);
GNUNET_free (*dst);
}