merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

commit fd5188e7dd1d5a2263919347d37fb82bcd4c9778
parent 30c85e657b552c3287d80c38cda3f6ec98fa48a3
Author: Christian Grothoff <christian@grothoff.org>
Date:   Tue, 26 May 2026 00:18:31 +0200

more minor fixes

Diffstat:
Msrc/util/contract_choice_parse.c | 69+++++++++++++++++++++++++++++++++++++++++++--------------------------
Msrc/util/token_family_parse.c | 2++
2 files changed, 45 insertions(+), 26 deletions(-)

diff --git a/src/util/contract_choice_parse.c b/src/util/contract_choice_parse.c @@ -30,6 +30,41 @@ #include "taler/taler_merchant_util.h" +/** + * Free contract choice output details in @a output, but not @a output itself + * + * @param[in,out] output contract output details to clean up + */ +static void +contract_choice_output_free ( + struct TALER_MERCHANT_ContractOutput *output) +{ + + switch (output->type) + { + case TALER_MERCHANT_CONTRACT_OUTPUT_TYPE_INVALID: + GNUNET_break (0); + break; + case TALER_MERCHANT_CONTRACT_OUTPUT_TYPE_TOKEN: + break; + case TALER_MERCHANT_CONTRACT_OUTPUT_TYPE_DONATION_RECEIPT: + for (unsigned int j = 0; + j<output->details.donation_receipt.donau_urls_len; + j++) + GNUNET_free (output->details.donation_receipt.donau_urls[j]); + GNUNET_array_grow (output->details.donation_receipt.donau_urls, + output->details.donation_receipt.donau_urls_len, + 0); + break; +#if FUTURE + case TALER_MERCHANT_CONTRACT_OUTPUT_TYPE_COIN: + GNUNET_free (output->details.coin.exchange_url); + break; +#endif + } +} + + enum GNUNET_GenericReturnValue TALER_MERCHANT_parse_contract_choice_input ( json_t *root, @@ -70,8 +105,8 @@ TALER_MERCHANT_parse_contract_choice_input ( GNUNET_JSON_spec_string ("token_family_slug", &input->details.token.token_family_slug), GNUNET_JSON_spec_mark_optional ( - GNUNET_JSON_spec_uint32 ("count", - &input->details.token.count), + GNUNET_JSON_spec_uint ("count", + &input->details.token.count), NULL), GNUNET_JSON_spec_end () }; @@ -379,17 +414,22 @@ parse_contract_choices ( idx)) { GNUNET_break (0); + contract_choice_output_free (&output); return GNUNET_SYSERR; } switch (output.type) { case TALER_MERCHANT_CONTRACT_OUTPUT_TYPE_INVALID: GNUNET_break_op (0); + contract_choice_output_free (&output); return GNUNET_SYSERR; case TALER_MERCHANT_CONTRACT_OUTPUT_TYPE_TOKEN: /* Ignore output tokens with 'count' field set to 0 */ if (0 == output.details.token.count) + { + contract_choice_output_free (&output); continue; + } break; case TALER_MERCHANT_CONTRACT_OUTPUT_TYPE_DONATION_RECEIPT: break; @@ -428,30 +468,7 @@ TALER_MERCHANT_contract_choice_free ( { for (unsigned int i = 0; i < choice->outputs_len; i++) { - struct TALER_MERCHANT_ContractOutput *output = &choice->outputs[i]; - - switch (output->type) - { - case TALER_MERCHANT_CONTRACT_OUTPUT_TYPE_INVALID: - GNUNET_break (0); - break; - case TALER_MERCHANT_CONTRACT_OUTPUT_TYPE_TOKEN: - break; - case TALER_MERCHANT_CONTRACT_OUTPUT_TYPE_DONATION_RECEIPT: - for (unsigned int j = 0; - j<output->details.donation_receipt.donau_urls_len; - j++) - GNUNET_free (output->details.donation_receipt.donau_urls[j]); - GNUNET_array_grow (output->details.donation_receipt.donau_urls, - output->details.donation_receipt.donau_urls_len, - 0); - break; -#if FUTURE - case TALER_MERCHANT_CONTRACT_OUTPUT_TYPE_COIN: - GNUNET_free (output->details.coin.exchange_url); - break; -#endif - } + contract_choice_output_free (&choice->outputs[i]); } GNUNET_free (choice->description); if (NULL != choice->description_i18n) diff --git a/src/util/token_family_parse.c b/src/util/token_family_parse.c @@ -341,6 +341,7 @@ parse_token_families (void *cls, error_line, error_name); GNUNET_break_op (0); + TALER_MERCHANT_contract_token_family_free (&family); return GNUNET_SYSERR; } @@ -379,6 +380,7 @@ parse_token_families (void *cls, ierror_line, ierror_name); GNUNET_break_op (0); + TALER_MERCHANT_contract_token_family_free (&family); return GNUNET_SYSERR; } }