From 8843d60e683157f40e1908a4dc57b82f6f6bb6ee Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 15 Sep 2019 10:54:10 +0200 Subject: fix memory leak and style issues --- src/wire-plugins/plugin_wire_taler-bank.c | 22 +++++++++++++++++----- .../test_wire_plugin_transactions_taler-bank.c | 7 +++---- 2 files changed, 20 insertions(+), 9 deletions(-) (limited to 'src/wire-plugins') diff --git a/src/wire-plugins/plugin_wire_taler-bank.c b/src/wire-plugins/plugin_wire_taler-bank.c index 97b1e6c84..e1db643d3 100644 --- a/src/wire-plugins/plugin_wire_taler-bank.c +++ b/src/wire-plugins/plugin_wire_taler-bank.c @@ -765,7 +765,8 @@ struct TALER_WIRE_HistoryHandle { /** - * Function to call with results. + * Function to call with results, can become NULL if the + * application cancels the iteration. */ TALER_WIRE_HistoryResultCallback hres_cb; @@ -797,6 +798,7 @@ static void taler_bank_get_history_cancel (void *cls, struct TALER_WIRE_HistoryHandle *whh) { + (void) cls; if (NULL != whh->hh) { TALER_BANK_history_cancel (whh->hh); @@ -893,7 +895,11 @@ bhist_cb (void *cls, GNUNET_break (NULL != whh->hh); /* Once we get the sentinel element, the handle becomes invalid. */ if (TALER_BANK_DIRECTION_NONE == dir) + { whh->hh = NULL; + taler_bank_get_history_cancel (NULL, + whh); + } return; } case MHD_HTTP_NO_CONTENT: @@ -904,6 +910,9 @@ bhist_cb (void *cls, NULL, 0, NULL); + whh->hh = NULL; + taler_bank_get_history_cancel (NULL, + whh); break; default: GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -917,6 +926,9 @@ bhist_cb (void *cls, NULL, 0, NULL); + whh->hh = NULL; + taler_bank_get_history_cancel (NULL, + whh); break; } whh->hh = NULL; @@ -962,6 +974,7 @@ taler_bank_get_history (void *cls, uint64_t start_row; struct TALER_Account account; + GNUNET_assert (NULL != hres_cb); if (0 == num_results) { GNUNET_break (0); @@ -1019,13 +1032,12 @@ taler_bank_get_history (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not parse the auth values from '%s'\n", account_section); + TALER_WIRE_account_free (&account); GNUNET_free (whh); return NULL; } - whh->hres_cb = hres_cb; whh->hres_cb_cls = hres_cb_cls; - whh->hh = TALER_BANK_history (tc->ctx, account.details.x_taler_bank.bank_base_url, &whh->auth, @@ -1040,16 +1052,16 @@ taler_bank_get_history (void *cls, if (NULL == whh->hh) { GNUNET_break (0); - taler_bank_get_history_cancel (NULL, + taler_bank_get_history_cancel (tc, whh); TALER_WIRE_account_free (&account); return NULL; } TALER_WIRE_account_free (&account); - GNUNET_assert (NULL != whh); return whh; } + /** * Context for a rejection operation. */ diff --git a/src/wire-plugins/test_wire_plugin_transactions_taler-bank.c b/src/wire-plugins/test_wire_plugin_transactions_taler-bank.c index 2cda49a05..fa0db5b41 100644 --- a/src/wire-plugins/test_wire_plugin_transactions_taler-bank.c +++ b/src/wire-plugins/test_wire_plugin_transactions_taler-bank.c @@ -107,6 +107,7 @@ static struct TALER_WireTransferIdentifierRawP wtid; static void do_shutdown (void *cls) { + (void) cls; TALER_FAKEBANK_stop (fb); fb = NULL; if (NULL != eh) @@ -186,11 +187,11 @@ history_result_cb uint64_t serialh; struct TALER_Amount amount; - hh = NULL; if ( (TALER_BANK_DIRECTION_NONE == dir) && (GNUNET_OK == global_ret) ) { GNUNET_SCHEDULER_shutdown (); + hh = NULL; return GNUNET_OK; } if (sizeof (uint64_t) != row_off_size) @@ -251,6 +252,7 @@ confirmation_cb (void *cls, const char *emsg) { uint64_t tmp; + eh = NULL; if (GNUNET_OK != success) { @@ -259,13 +261,10 @@ confirmation_cb (void *cls, GNUNET_SCHEDULER_shutdown (); return; } - memcpy (&tmp, row_id, row_id_size); - serial_target = GNUNET_ntohll (tmp); - hh = plugin->get_history (plugin->cls, my_account, TALER_BANK_DIRECTION_BOTH, -- cgit v1.2.3