From 59fd83b73128d8393726caf58016b81b86cc3404 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 4 Jun 2017 12:07:53 +0200 Subject: fix memory leaks (#5050) --- .gitignore | 1 + Makefile.am | 2 + src/bank-lib/fakebank.c | 1 + src/exchange-lib/exchange_api_reserve.c | 68 ++++++++++++++++++++++++++------- 4 files changed, 58 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 7f0c79eb7..4b4c4123a 100644 --- a/.gitignore +++ b/.gitignore @@ -84,3 +84,4 @@ doc/manual/manual.toc doc/manual/manual.tp doc/manual/manual.vr contrib/taler-exchange.tag +doxygen-doc/ diff --git a/Makefile.am b/Makefile.am index a73d4d863..ab0f3acc4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -13,6 +13,8 @@ ACLOCAL_AMFLAGS = -I m4 EXTRA_DIST = \ AUTHORS \ contrib/coverage.sh \ + contrib/gnunet.tag \ + contrib/microhttpd.tag \ Doxyfile app: diff --git a/src/bank-lib/fakebank.c b/src/bank-lib/fakebank.c index 924e0656a..ceda4d37b 100644 --- a/src/bank-lib/fakebank.c +++ b/src/bank-lib/fakebank.c @@ -361,6 +361,7 @@ handle_admin_add_incoming (struct TALER_FAKEBANK_Handle *h, (json_int_t) t->serial_id); json_str = json_dumps (json, JSON_INDENT(2)); + json_decref (json); if (NULL == json_str) { GNUNET_break (0); diff --git a/src/exchange-lib/exchange_api_reserve.c b/src/exchange-lib/exchange_api_reserve.c index 7649cccda..c7b486f0c 100644 --- a/src/exchange-lib/exchange_api_reserve.c +++ b/src/exchange-lib/exchange_api_reserve.c @@ -409,11 +409,42 @@ parse_reserve_history (struct TALER_EXCHANGE_Handle *exchange, GNUNET_break_op (0); return GNUNET_SYSERR; } - return GNUNET_OK; } +/** + * Free memory (potentially) allocated by #parse_reserve_history(). + * + * @param rhistory result to free + * @param len number of entries in @a rhistory + */ +static void +free_rhistory (struct TALER_EXCHANGE_ReserveHistory *rhistory, + unsigned int len) +{ + for (unsigned int i=0;iexchange, history, @@ -479,25 +511,29 @@ handle_reserve_status_finished (void *cls, { GNUNET_break_op (0); response_code = 0; - break; } - if (0 != - TALER_amount_cmp (&balance_from_history, - &balance)) + if ( (0 != response_code) && + (0 != + TALER_amount_cmp (&balance_from_history, + &balance)) ) { /* exchange cannot add up balances!? */ GNUNET_break_op (0); response_code = 0; - break; } - rsh->cb (rsh->cb_cls, - response_code, - TALER_EC_NONE, - json, - &balance, - len, - rhistory); - rsh->cb = NULL; + if (0 != response_code) + { + rsh->cb (rsh->cb_cls, + response_code, + TALER_EC_NONE, + json, + &balance, + len, + rhistory); + rsh->cb = NULL; + } + free_rhistory (rhistory, + len); } } break; @@ -796,8 +832,12 @@ reserve_withdraw_payment_required (struct TALER_EXCHANGE_ReserveWithdrawHandle * rhistory)) { GNUNET_break_op (0); + free_rhistory (rhistory, + len); return GNUNET_SYSERR; } + free_rhistory (rhistory, + len); } if (0 != -- cgit v1.2.3