commit ed040676c2410b1764e68f8ebb648d2c01c60e31
parent 3e525220dd33b19203ffce1d44728a620e49da68
Author: Christian Grothoff <christian@grothoff.org>
Date: Mon, 25 May 2026 23:39:31 +0200
more conservative against NULL pc
Diffstat:
2 files changed, 31 insertions(+), 31 deletions(-)
diff --git a/src/util/contract_parse.c b/src/util/contract_parse.c
@@ -262,25 +262,6 @@ void
TALER_MERCHANT_proto_contract_free (
struct TALER_MERCHANT_ProtoContract *pc)
{
- switch (pc->base->version)
- {
- case TALER_MERCHANT_CONTRACT_VERSION_0:
- break;
- case TALER_MERCHANT_CONTRACT_VERSION_1:
- for (unsigned int i = 0;
- i < pc->details.v1.choices_len;
- i++)
- TALER_MERCHANT_contract_choice_free (
- &pc->details.v1.choices[i]);
- GNUNET_free (pc->details.v1.choices);
- for (unsigned int i = 0;
- i < pc->details.v1.token_authorities_len;
- i++)
- TALER_MERCHANT_contract_token_family_free (
- &pc->details.v1.token_authorities[i]);
- GNUNET_free (pc->details.v1.token_authorities);
- break;
- }
if (NULL != pc->products)
{
for (size_t i = 0; i<pc->products_len; i++)
@@ -289,6 +270,25 @@ TALER_MERCHANT_proto_contract_free (
}
if (NULL != pc->base)
{
+ switch (pc->base->version)
+ {
+ case TALER_MERCHANT_CONTRACT_VERSION_0:
+ break;
+ case TALER_MERCHANT_CONTRACT_VERSION_1:
+ for (unsigned int i = 0;
+ i < pc->details.v1.choices_len;
+ i++)
+ TALER_MERCHANT_contract_choice_free (
+ &pc->details.v1.choices[i]);
+ GNUNET_free (pc->details.v1.choices);
+ for (unsigned int i = 0;
+ i < pc->details.v1.token_authorities_len;
+ i++)
+ TALER_MERCHANT_contract_token_family_free (
+ &pc->details.v1.token_authorities[i]);
+ GNUNET_free (pc->details.v1.token_authorities);
+ break;
+ }
TALER_MERCHANT_base_terms_free (pc->base);
pc->base = NULL;
}
diff --git a/src/util/order_parse.c b/src/util/order_parse.c
@@ -261,18 +261,6 @@ TALER_MERCHANT_order_free (
{
if (NULL == order)
return;
- switch (order->base->version)
- {
- case TALER_MERCHANT_CONTRACT_VERSION_0:
- break;
- case TALER_MERCHANT_CONTRACT_VERSION_1:
- for (unsigned int i = 0;
- i < order->details.v1.choices_len;
- i++)
- TALER_MERCHANT_order_choice_free (&order->details.v1.choices[i]);
- GNUNET_free (order->details.v1.choices);
- break;
- }
if (NULL != order->products)
{
for (size_t i = 0; i<order->products_len; i++)
@@ -283,6 +271,18 @@ TALER_MERCHANT_order_free (
GNUNET_free (order->order_id);
if (NULL != order->base)
{
+ switch (order->base->version)
+ {
+ case TALER_MERCHANT_CONTRACT_VERSION_0:
+ break;
+ case TALER_MERCHANT_CONTRACT_VERSION_1:
+ for (unsigned int i = 0;
+ i < order->details.v1.choices_len;
+ i++)
+ TALER_MERCHANT_order_choice_free (&order->details.v1.choices[i]);
+ GNUNET_free (order->details.v1.choices);
+ break;
+ }
TALER_MERCHANT_base_terms_free (order->base);
order->base = NULL;
}