summaryrefslogtreecommitdiff
path: root/src/exchange/taler-exchange-httpd_wire.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-02-13 18:22:07 +0100
committerChristian Grothoff <christian@grothoff.org>2021-02-13 18:22:07 +0100
commit246f3a7f948b5e50109e7adfaf4170fb3e096409 (patch)
treee9295d59caedc73cd093fd10c46785133e519f98 /src/exchange/taler-exchange-httpd_wire.c
parent12deb6c2670f663a3c0734e28673f508fffa3210 (diff)
downloadexchange-246f3a7f948b5e50109e7adfaf4170fb3e096409.tar.gz
exchange-246f3a7f948b5e50109e7adfaf4170fb3e096409.tar.bz2
exchange-246f3a7f948b5e50109e7adfaf4170fb3e096409.zip
simplify logic, fix leak
Diffstat (limited to 'src/exchange/taler-exchange-httpd_wire.c')
-rw-r--r--src/exchange/taler-exchange-httpd_wire.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/src/exchange/taler-exchange-httpd_wire.c b/src/exchange/taler-exchange-httpd_wire.c
index e01355c60..8f78f3b60 100644
--- a/src/exchange/taler-exchange-httpd_wire.c
+++ b/src/exchange/taler-exchange-httpd_wire.c
@@ -198,7 +198,6 @@ build_wire_state (void)
{
json_t *wire_accounts_array;
json_t *wire_fee_object;
- json_t *wire_reply;
uint64_t wg = wire_generation; /* must be obtained FIRST */
enum GNUNET_DB_QueryStatus qs;
@@ -230,6 +229,7 @@ build_wire_state (void)
char *wire_method;
const char *payto_uri = json_string_value (json_object_get (account,
"payto_uri"));
+
GNUNET_assert (NULL != payto_uri);
wire_method = TALER_payto_get_method (payto_uri);
if (NULL == wire_method)
@@ -265,6 +265,7 @@ build_wire_state (void)
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"No wire fees for `%s' configured. Administrator must set `wire-fee` with taler-exchange-offline!\n",
wire_method);
+ json_decref (a);
json_decref (wire_accounts_array);
json_decref (wire_fee_object);
GNUNET_free (wire_method);
@@ -276,25 +277,25 @@ build_wire_state (void)
a));
}
GNUNET_free (wire_method);
-
}
}
- wire_reply = json_pack (
- "{s:o, s:o, s:o}",
- "accounts",
- wire_accounts_array,
- "fees",
- wire_fee_object,
- "master_public_key",
- GNUNET_JSON_from_data_auto (&TEH_master_public_key));
- if (NULL == wire_reply)
- {
- GNUNET_break (0);
- return NULL;
- }
{
+ json_t *wire_reply;
struct WireStateHandle *wsh;
+ wire_reply = json_pack (
+ "{s:o, s:o, s:o}",
+ "accounts",
+ wire_accounts_array,
+ "fees",
+ wire_fee_object,
+ "master_public_key",
+ GNUNET_JSON_from_data_auto (&TEH_master_public_key));
+ if (NULL == wire_reply)
+ {
+ GNUNET_break (0);
+ return NULL;
+ }
wsh = GNUNET_new (struct WireStateHandle);
wsh->wire_reply = wire_reply;
wsh->wire_generation = wg;
@@ -322,12 +323,13 @@ struct WireStateHandle *
get_wire_state (void)
{
struct WireStateHandle *old_wsh;
- struct WireStateHandle *wsh;
old_wsh = pthread_getspecific (wire_state);
if ( (NULL == old_wsh) ||
(old_wsh->wire_generation < wire_generation) )
{
+ struct WireStateHandle *wsh;
+
wsh = build_wire_state ();
if (NULL == wsh)
return NULL;