summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-06-04 23:07:57 +0200
committerChristian Grothoff <christian@grothoff.org>2017-06-04 23:07:57 +0200
commitbfd145a56ca687f0ede011a5258129d8be839742 (patch)
tree1ad15834f06584b08995eecb437aea72e1628f1e
parent979e9d380d6169034f9f426a3b2b050ac4907200 (diff)
downloadmerchant-bfd145a56ca687f0ede011a5258129d8be839742.tar.gz
merchant-bfd145a56ca687f0ede011a5258129d8be839742.tar.bz2
merchant-bfd145a56ca687f0ede011a5258129d8be839742.zip
fix more leaks
-rw-r--r--src/backend/taler-merchant-httpd_pay.c6
-rw-r--r--src/backend/taler-merchant-httpd_proposal.c6
-rw-r--r--src/backend/taler-merchant-httpd_track-transfer.c1
-rw-r--r--src/backenddb/plugin_merchantdb_postgres.c96
-rw-r--r--src/include/taler_merchantdb_plugin.h2
-rw-r--r--src/lib/merchant_api_history.c10
-rw-r--r--src/lib/merchant_api_track_transaction.c4
-rw-r--r--src/lib/merchant_api_track_transfer.c4
8 files changed, 59 insertions, 70 deletions
diff --git a/src/backend/taler-merchant-httpd_pay.c b/src/backend/taler-merchant-httpd_pay.c
index 97b7ac4d..837b17d7 100644
--- a/src/backend/taler-merchant-httpd_pay.c
+++ b/src/backend/taler-merchant-httpd_pay.c
@@ -1316,12 +1316,10 @@ handler_pay_json (struct MHD_Connection *connection,
and accept immediately */
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Payment succeeded in the past; taking short cut");
- resp = MHD_create_response_from_buffer (0,
- NULL,
- MHD_RESPMEM_PERSISTENT);
+ resp = sign_success_response (pc);
ret = MHD_queue_response (connection,
MHD_HTTP_OK,
- sign_success_response (pc));
+ resp);
MHD_destroy_response (resp);
return ret;
}
diff --git a/src/backend/taler-merchant-httpd_proposal.c b/src/backend/taler-merchant-httpd_proposal.c
index e2332efc..a4311795 100644
--- a/src/backend/taler-merchant-httpd_proposal.c
+++ b/src/backend/taler-merchant-httpd_proposal.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- (C) 2014, 2015, 2016 INRIA
+ (C) 2014, 2015, 2016, 2017 INRIA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License as published by the Free Software
@@ -14,7 +14,7 @@
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
/**
- * @file backend/taler-merchant-httpd_propose.c
+ * @file backend/taler-merchant-httpd_proposal.c
* @brief HTTP serving layer mainly intended to communicate with the frontend
* @author Marcello Stanisci
*/
@@ -455,4 +455,4 @@ MH_handler_proposal_lookup (struct TMH_RequestHandler *rh,
}
-/* end of taler-merchant-httpd_contract.c */
+/* end of taler-merchant-httpd_proposal.c */
diff --git a/src/backend/taler-merchant-httpd_track-transfer.c b/src/backend/taler-merchant-httpd_track-transfer.c
index a0dadabe..5eeff5b1 100644
--- a/src/backend/taler-merchant-httpd_track-transfer.c
+++ b/src/backend/taler-merchant-httpd_track-transfer.c
@@ -719,6 +719,7 @@ proof_cb (void *cls,
rctx->response_code = MHD_HTTP_OK;
rctx->response = TMH_RESPONSE_make_json (transformed_response);
+ json_decref (transformed_response);
}
diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c
index 3903d172..5237e767 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -397,44 +397,35 @@ postgres_find_contract_terms_from_hash (void *cls,
const struct TALER_MerchantPublicKeyP *merchant_pub)
{
struct PostgresClosure *pg = cls;
- PGresult *result;
- unsigned int i;
-
+ enum GNUNET_PQ_QueryStatus res;
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (h_contract_terms),
GNUNET_PQ_query_param_auto_from_type (merchant_pub),
GNUNET_PQ_query_param_end
};
-
- result = GNUNET_PQ_exec_prepared (pg->conn,
- "find_contract_terms_from_hash",
- params);
- i = PQntuples (result);
- if (1 < i)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Mupltiple proposal data hash the same hashcode!\n");
- return GNUNET_SYSERR;
- }
-
- if (0 == i)
- return GNUNET_NO;
-
struct GNUNET_PQ_ResultSpec rs[] = {
TALER_PQ_result_spec_json ("contract_terms",
contract_terms),
GNUNET_PQ_result_spec_end
};
- if (GNUNET_OK !=
- GNUNET_PQ_extract_result (result,
- rs,
- 0))
+
+ res = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
+ "find_contract_terms_from_hash",
+ params,
+ rs);
+ if (res < 0)
{
GNUNET_break (0);
- PQclear (result);
return GNUNET_SYSERR;
}
-
+ if (1 < res)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Mupltiple proposal data hash the same hashcode!\n");
+ return GNUNET_SYSERR;
+ }
+ if (0 == res)
+ return GNUNET_NO;
return GNUNET_OK;
}
@@ -443,61 +434,52 @@ postgres_find_contract_terms_from_hash (void *cls,
* Retrieve proposal data given its order id.
*
* @param cls closure
- * @param contract_terms where to store the retrieved proposal data
+ * @param[out] contract_terms where to store the retrieved proposal data
* @param order id order id used to perform the lookup
* @return #GNUNET_OK on success, #GNUNET_NO if no proposal is
* found, #GNUNET_SYSERR upon error
*/
static int
postgres_find_contract_terms (void *cls,
- json_t **contract_terms,
- const char *order_id,
- const struct TALER_MerchantPublicKeyP *merchant_pub)
+ json_t **contract_terms,
+ const char *order_id,
+ const struct TALER_MerchantPublicKeyP *merchant_pub)
{
struct PostgresClosure *pg = cls;
- PGresult *result;
- unsigned int i;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "finding contract term, order_id: '%s', merchant_pub: '%s'.\n",
- order_id,
- TALER_B2S (merchant_pub));
-
+ enum GNUNET_PQ_QueryStatus res;
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_string (order_id),
GNUNET_PQ_query_param_auto_from_type (merchant_pub),
GNUNET_PQ_query_param_end
};
-
- result = GNUNET_PQ_exec_prepared (pg->conn,
- "find_contract_terms",
- params);
- i = PQntuples (result);
- if (1 < i)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Mupltiple proposal data share the same hashcode.\n");
- return GNUNET_SYSERR;
- }
-
- if (0 == i)
- return GNUNET_NO;
-
struct GNUNET_PQ_ResultSpec rs[] = {
TALER_PQ_result_spec_json ("contract_terms",
contract_terms),
GNUNET_PQ_result_spec_end
};
- if (GNUNET_OK !=
- GNUNET_PQ_extract_result (result,
- rs,
- 0))
+
+ *contract_terms = NULL;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Finding contract term, order_id: '%s', merchant_pub: '%s'.\n",
+ order_id,
+ TALER_B2S (merchant_pub));
+ res = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
+ "find_contract_terms",
+ params,
+ rs);
+ if (res < 0)
{
GNUNET_break (0);
- PQclear (result);
return GNUNET_SYSERR;
}
-
+ if (res > 1)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Mupltiple proposal data share the same hashcode.\n");
+ return GNUNET_SYSERR;
+ }
+ if (0 == res)
+ return GNUNET_NO;
return GNUNET_OK;
}
diff --git a/src/include/taler_merchantdb_plugin.h b/src/include/taler_merchantdb_plugin.h
index db27e0eb..0a390f5b 100644
--- a/src/include/taler_merchantdb_plugin.h
+++ b/src/include/taler_merchantdb_plugin.h
@@ -183,7 +183,7 @@ struct TALER_MERCHANTDB_Plugin
* Retrieve proposal data given its order ID.
*
* @param cls closure
- * @param contract_terms where to store the result
+ * @param[out] contract_terms where to store the result
* @param order_id order_id used to lookup.
* @param merchant_pub instance's public key.
* @return #GNUNET_OK on success, #GNUNET_NO if no contract is
diff --git a/src/lib/merchant_api_history.c b/src/lib/merchant_api_history.c
index a2c2d5fa..ab4c6f44 100644
--- a/src/lib/merchant_api_history.c
+++ b/src/lib/merchant_api_history.c
@@ -95,7 +95,6 @@ history_raw_cb (void *cls,
struct TALER_MERCHANT_HistoryOperation *ho = cls;
ho->job = NULL;
-
switch (response_code)
{
case 0:
@@ -105,8 +104,8 @@ history_raw_cb (void *cls,
MHD_HTTP_OK,
TALER_EC_NONE,
json);
+ TALER_MERCHANT_history_cancel (ho);
return;
- break;
case MHD_HTTP_INTERNAL_SERVER_ERROR:
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"/history URI not found\n");
@@ -128,6 +127,7 @@ history_raw_cb (void *cls,
response_code,
TALER_JSON_get_error_code (json),
json);
+ TALER_MERCHANT_history_cancel (ho);
}
@@ -178,9 +178,9 @@ TALER_MERCHANT_history (struct GNUNET_CURL_Context *ctx,
CURLOPT_URL,
ho->url))
{
- GNUNET_break (0);
+ GNUNET_break (0);
return NULL;
- }
+ }
if (NULL == (ho->job = GNUNET_CURL_job_add (ctx,
eh,
@@ -192,7 +192,7 @@ TALER_MERCHANT_history (struct GNUNET_CURL_Context *ctx,
return NULL;
}
return ho;
-}
+}
/* end of merchant_api_contract.c */
diff --git a/src/lib/merchant_api_track_transaction.c b/src/lib/merchant_api_track_transaction.c
index 4e11accd..560408f2 100644
--- a/src/lib/merchant_api_track_transaction.c
+++ b/src/lib/merchant_api_track_transaction.c
@@ -109,7 +109,10 @@ handle_track_transaction_finished (void *cls,
if (GNUNET_OK ==
parse_track_transaction_ok (tdo,
json))
+ {
+ TALER_MERCHANT_track_transaction_cancel (tdo);
return;
+ }
response_code = 0;
break;
case MHD_HTTP_ACCEPTED:
@@ -140,6 +143,7 @@ handle_track_transaction_finished (void *cls,
response_code,
TALER_JSON_get_error_code (json),
json);
+ TALER_MERCHANT_track_transaction_cancel (tdo);
}
diff --git a/src/lib/merchant_api_track_transfer.c b/src/lib/merchant_api_track_transfer.c
index 0de4ac80..fcd208ce 100644
--- a/src/lib/merchant_api_track_transfer.c
+++ b/src/lib/merchant_api_track_transfer.c
@@ -173,7 +173,10 @@ handle_track_transfer_finished (void *cls,
if (GNUNET_OK ==
check_track_transfer_response_ok (tdo,
json))
+ {
+ TALER_MERCHANT_track_transfer_cancel (tdo);
return;
+ }
GNUNET_break_op (0);
response_code = 0;
break;
@@ -203,6 +206,7 @@ handle_track_transfer_finished (void *cls,
NULL,
0,
NULL);
+ TALER_MERCHANT_track_transfer_cancel (tdo);
}