From b3ddcd0dbb6cf0db09f7bd156d73b3cb8e284e2d Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 27 Aug 2021 14:58:46 +0200 Subject: -fix misc. memory leaks --- src/reducer/anastasis_api_backup_redux.c | 22 +++++++++++++++++++++- src/reducer/anastasis_api_redux.c | 1 + 2 files changed, 22 insertions(+), 1 deletion(-) (limited to 'src/reducer') diff --git a/src/reducer/anastasis_api_backup_redux.c b/src/reducer/anastasis_api_backup_redux.c index 27a79c0..e025810 100644 --- a/src/reducer/anastasis_api_backup_redux.c +++ b/src/reducer/anastasis_api_backup_redux.c @@ -835,6 +835,9 @@ eval_provider_selection (struct PolicyBuilder *pb, unsigned int curr_diversity; struct PolicyEntry policy_ent[pb->req_methods]; + memset (policy_ent, + 0, + sizeof (policy_ent)); for (unsigned int i = 0; i < pb->req_methods; i++) { const json_t *method_obj = json_array_get (pb->methods, @@ -869,7 +872,6 @@ eval_provider_selection (struct PolicyBuilder *pb, }; policy_ent[i].provider_name = prov_sel[i]; - policy_ent[i].usage_fee = NULL; if (GNUNET_OK != GNUNET_JSON_parse (method_obj, mspec, @@ -878,6 +880,8 @@ eval_provider_selection (struct PolicyBuilder *pb, GNUNET_break (0); pb->ec = TALER_EC_ANASTASIS_REDUCER_INPUT_INVALID; pb->hint = "'authentication_method' content malformed"; + for (unsigned int i = 0; ireq_methods; i++) + free_costs (policy_ent[i].usage_fee); return; } @@ -886,6 +890,8 @@ eval_provider_selection (struct PolicyBuilder *pb, "http_status"))) { GNUNET_JSON_parse_free (mspec); + for (unsigned int i = 0; ireq_methods; i++) + free_costs (policy_ent[i].usage_fee); return; /* skip providers that are down */ } if (GNUNET_OK != @@ -897,6 +903,8 @@ eval_provider_selection (struct PolicyBuilder *pb, "Skipping provider %s: no suitable configuration\n", prov_sel[i]); GNUNET_JSON_parse_free (mspec); + for (unsigned int i = 0; ireq_methods; i++) + free_costs (policy_ent[i].usage_fee); return; } json_array_foreach (provider_methods, index, md) @@ -920,6 +928,8 @@ eval_provider_selection (struct PolicyBuilder *pb, pb->ec = TALER_EC_ANASTASIS_REDUCER_STATE_INVALID; pb->hint = "'methods' of provider"; GNUNET_JSON_parse_free (pspec); + for (unsigned int i = 0; ireq_methods; i++) + free_costs (policy_ent[i].usage_fee); return; } if ( (0 == strcmp (type, @@ -941,6 +951,8 @@ eval_provider_selection (struct PolicyBuilder *pb, Cost is basically 'infinite', but we simply then skip this. */ GNUNET_JSON_parse_free (pspec); GNUNET_JSON_parse_free (mspec); + for (unsigned int i = 0; ireq_methods; i++) + free_costs (policy_ent[i].usage_fee); return; } GNUNET_JSON_parse_free (mspec); @@ -972,8 +984,12 @@ eval_provider_selection (struct PolicyBuilder *pb, pb->best_diversity); #endif if (curr_diversity < pb->best_diversity) + { + for (unsigned int i = 0; ireq_methods; i++) + free_costs (policy_ent[i].usage_fee); return; /* do not allow combinations that are bad for provider diversity */ + } if (curr_diversity > pb->best_diversity) { /* drop existing policies, they are all worse */ @@ -1016,7 +1032,11 @@ eval_provider_selection (struct PolicyBuilder *pb, } } if (equiv) + { + for (unsigned int i = 0; ireq_methods; i++) + free_costs (policy_ent[i].usage_fee); return; /* equivalent to known allocation */ + } } } diff --git a/src/reducer/anastasis_api_redux.c b/src/reducer/anastasis_api_redux.c index bd14285..6262033 100644 --- a/src/reducer/anastasis_api_redux.c +++ b/src/reducer/anastasis_api_redux.c @@ -349,6 +349,7 @@ free_config_request (struct ConfigRequest *cr) GNUNET_free (cr->business_name); for (unsigned int i = 0; imethods_length; i++) GNUNET_free (cr->methods[i].type); + GNUNET_free (cr->business_name); GNUNET_free (cr->methods); GNUNET_free (cr); } -- cgit v1.2.3