aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-06-11 16:47:04 +0200
committerChristian Grothoff <christian@grothoff.org>2016-06-11 16:47:04 +0200
commit489eaecb1d8669a6827c94b2d1e9ac84bbeab2ad (patch)
treecff6e557862cbef4a3f190c44bed0dfa525fddbe
parent0e8cba34585ddd76aae0803b5d1721f8dd4cc51a (diff)
fix leaks
-rw-r--r--src/lib/merchant_api_pay.c11
-rw-r--r--src/lib/merchant_api_track_transfer.c3
-rw-r--r--src/lib/test_merchant_api.c6
3 files changed, 17 insertions, 3 deletions
diff --git a/src/lib/merchant_api_pay.c b/src/lib/merchant_api_pay.c
index 5a6127af..7dcc5fe7 100644
--- a/src/lib/merchant_api_pay.c
+++ b/src/lib/merchant_api_pay.c
@@ -151,6 +151,7 @@ check_forbidden (struct TALER_MERCHANT_Pay *ph,
GNUNET_JSON_spec_end()
};
unsigned int i;
+ int ret;
if (GNUNET_OK !=
GNUNET_JSON_parse (json,
@@ -165,11 +166,16 @@ check_forbidden (struct TALER_MERCHANT_Pay *ph,
if (0 == memcmp (&ph->coins[i].coin_pub,
&coin_pub,
sizeof (struct TALER_CoinSpendPublicKeyP)))
- return check_coin_history (&ph->coins[i],
- history);
+ {
+ ret = check_coin_history (&ph->coins[i],
+ history);
+ GNUNET_JSON_parse_free (spec);
+ return ret;
+ }
}
GNUNET_break_op (0); /* complaint is not about any of the coins
that we actually paid with... */
+ GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
@@ -615,6 +621,7 @@ TALER_MERCHANT_pay_cancel (struct TALER_MERCHANT_Pay *pay)
GNUNET_CURL_job_cancel (pay->job);
pay->job = NULL;
}
+ GNUNET_free (pay->coins);
GNUNET_free (pay->url);
GNUNET_free (pay->json_enc);
GNUNET_free (pay);
diff --git a/src/lib/merchant_api_track_transfer.c b/src/lib/merchant_api_track_transfer.c
index 61d9e1f0..c356a6aa 100644
--- a/src/lib/merchant_api_track_transfer.c
+++ b/src/lib/merchant_api_track_transfer.c
@@ -132,6 +132,7 @@ parse_exchange_details_ok (struct TALER_MERCHANT_TrackTransferHandle *wdh,
NULL, NULL))
{
GNUNET_break_op (0);
+ GNUNET_JSON_parse_free (inner_spec);
return GNUNET_SYSERR;
}
}
@@ -144,6 +145,7 @@ parse_exchange_details_ok (struct TALER_MERCHANT_TrackTransferHandle *wdh,
num_details,
details);
}
+ GNUNET_JSON_parse_free (inner_spec);
return GNUNET_OK;
}
@@ -203,6 +205,7 @@ check_track_transfer_response_ok (struct TALER_MERCHANT_TrackTransferHandle *wdh
}
if (GNUNET_OK == ret)
TALER_MERCHANT_track_transfer_cancel (wdh);
+ GNUNET_JSON_parse_free (outer_spec);
return ret;
}
diff --git a/src/lib/test_merchant_api.c b/src/lib/test_merchant_api.c
index dec44a19..5811257f 100644
--- a/src/lib/test_merchant_api.c
+++ b/src/lib/test_merchant_api.c
@@ -1928,6 +1928,7 @@ run (void *cls)
.details.admin_add_incoming.sender_details = "{ \"type\":\"test\", \"bank_uri\":\"" BANK_URI "\", \"account_number\":62, \"uuid\":1 }",
.details.admin_add_incoming.transfer_details = "{ \"uuid\": 1}",
.details.admin_add_incoming.amount = "EUR:5.01" },
+
/* Withdraw a 5 EUR coin, at fee of 1 ct */
{ .oc = OC_WITHDRAW_SIGN,
.label = "withdraw-coin-1",
@@ -1946,6 +1947,8 @@ run (void *cls)
.label = "create-contract-1",
.expected_response_code = MHD_HTTP_OK,
.details.contract.proposal = "{ \"max_fee\":{\"currency\":\"EUR\", \"value\":0, \"fraction\":500000}, \"transaction_id\":1, \"timestamp\":\"\\/Date(42)\\/\", \"refund_deadline\":\"\\/Date(0)\\/\", \"expiry\":\"\\/Date(999999999)\\/\", \"amount\":{\"currency\":\"EUR\", \"value\":5, \"fraction\":0}, \"products\":[ {\"description\":\"ice cream\", \"value\":\"{EUR:5}\"} ] }" },
+
+
{ .oc = OC_PAY,
.label = "deposit-simple",
.expected_response_code = MHD_HTTP_OK,
@@ -1954,6 +1957,7 @@ run (void *cls)
.details.pay.amount_with_fee = "EUR:5",
.details.pay.amount_without_fee = "EUR:4.99" },
/* Create another contract */
+
{ .oc = OC_CONTRACT,
.label = "create-contract-2",
.expected_response_code = MHD_HTTP_OK,
@@ -1997,6 +2001,7 @@ run (void *cls)
{ .oc = OC_CHECK_BANK_TRANSFERS_EMPTY,
.label = "check_bank_empty" },
+
/* Run transfers. */
{ .oc = OC_RUN_AGGREGATOR,
.label = "run-aggregator" },
@@ -2071,7 +2076,6 @@ run (void *cls)
.details.track_transfer.expected_pay_ref = "deposit-simple-2"
},
-
/* end of testcase */
{ .oc = OC_END }
};