From afb1ab2a116bb0b33b5d23d043222965892e8edf Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 4 Apr 2016 17:40:51 +0200 Subject: -fix mem leaks --- src/exchange/taler-exchange-aggregator.c | 12 ++++++++++++ src/exchangedb/plugin_exchangedb_postgres.c | 9 +++++---- src/wire/plugin_wire_sepa.c | 24 ++++++++++++------------ src/wire/plugin_wire_test.c | 1 + 4 files changed, 30 insertions(+), 16 deletions(-) diff --git a/src/exchange/taler-exchange-aggregator.c b/src/exchange/taler-exchange-aggregator.c index 2d5fd71d8..a6b7de211 100644 --- a/src/exchange/taler-exchange-aggregator.c +++ b/src/exchange/taler-exchange-aggregator.c @@ -472,6 +472,8 @@ run_aggregation (void *cls, au); if (GNUNET_OK != ret) { + if (NULL != au->wire) + json_decref (au->wire); GNUNET_free (au); db_plugin->rollback (db_plugin->cls, session); @@ -510,6 +512,8 @@ run_aggregation (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to execute deposit iteration!\n"); GNUNET_free_non_null (au->additional_rows); + if (NULL != au->wire) + json_decref (au->wire); GNUNET_free (au); db_plugin->rollback (db_plugin->cls, session); @@ -538,6 +542,8 @@ run_aggregation (void *cls, "Failed to start database transaction!\n"); *global_ret = GNUNET_SYSERR; GNUNET_free_non_null (au->additional_rows); + if (NULL != au->wire) + json_decref (au->wire); GNUNET_free (au); return; } @@ -564,6 +570,8 @@ run_aggregation (void *cls, "Failed to commit database transaction!\n"); } GNUNET_free_non_null (au->additional_rows); + if (NULL != au->wire) + json_decref (au->wire); GNUNET_free (au); /* start again */ task = GNUNET_SCHEDULER_add_now (&run_aggregation, @@ -586,6 +594,8 @@ run_aggregation (void *cls, db_plugin->rollback (db_plugin->cls, session); GNUNET_free_non_null (au->additional_rows); + if (NULL != au->wire) + json_decref (au->wire); GNUNET_free (au); /* start again */ task = GNUNET_SCHEDULER_add_now (&run_aggregation, @@ -625,6 +635,8 @@ prepare_cb (void *cls, struct TALER_EXCHANGEDB_Session *session = au->session; GNUNET_free_non_null (au->additional_rows); + if (NULL != au->wire) + json_decref (au->wire); GNUNET_free (au); if (NULL == buf) { diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c index b59acaead..6807e7563 100644 --- a/src/exchangedb/plugin_exchangedb_postgres.c +++ b/src/exchangedb/plugin_exchangedb_postgres.c @@ -1480,8 +1480,8 @@ postgres_get_denomination_info (void *cls, EXITIF (GNUNET_OK != GNUNET_PQ_extract_result (result, - rs, - 0)); + rs, + 0)); } PQclear (result); return GNUNET_OK; @@ -1954,7 +1954,7 @@ postgres_get_reserve_history (void *cls, &bt->wire), GNUNET_PQ_result_spec_end }; - if (GNUNET_YES != + if (GNUNET_OK != GNUNET_PQ_extract_result (result, rs, --rows)) { GNUNET_break (0); @@ -2019,7 +2019,7 @@ postgres_get_reserve_history (void *cls, &cbc->withdraw_fee), GNUNET_PQ_result_spec_end }; - if (GNUNET_YES != + if (GNUNET_OK != GNUNET_PQ_extract_result (result, rs, --rows)) { GNUNET_break (0); @@ -2285,6 +2285,7 @@ postgres_get_ready_deposit (void *cls, &wire), GNUNET_PQ_result_spec_end }; + if (GNUNET_OK != GNUNET_PQ_extract_result (result, rs, 0)) { diff --git a/src/wire/plugin_wire_sepa.c b/src/wire/plugin_wire_sepa.c index 466e450be..e0a3426c2 100644 --- a/src/wire/plugin_wire_sepa.c +++ b/src/wire/plugin_wire_sepa.c @@ -731,20 +731,20 @@ libtaler_plugin_wire_sepa_init (void *cls) sc = GNUNET_new (struct SepaClosure); if (NULL != cfg) + { + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_string (cfg, + "exchange", + "CURRENCY", + &sc->currency)) { - if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_string (cfg, - "exchange", - "CURRENCY", - &sc->currency)) - { - GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, - "exchange", - "CURRENCY"); - GNUNET_free (sc); - return NULL; - } + GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, + "exchange", + "CURRENCY"); + GNUNET_free (sc); + return NULL; } + } plugin = GNUNET_new (struct TALER_WIRE_Plugin); plugin->cls = sc; plugin->amount_round = &sepa_amount_round; diff --git a/src/wire/plugin_wire_test.c b/src/wire/plugin_wire_test.c index 8c03d155e..357449af6 100644 --- a/src/wire/plugin_wire_test.c +++ b/src/wire/plugin_wire_test.c @@ -762,6 +762,7 @@ libtaler_plugin_wire_test_init (void *cls) return NULL; } tc->bank = TALER_BANK_init (uri); + GNUNET_free (uri); if (NULL == tc->bank) { GNUNET_break (0); -- cgit v1.2.3