summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-08-25 11:08:43 +0200
committerChristian Grothoff <christian@grothoff.org>2020-08-25 11:08:43 +0200
commit0acefc910ff1b86aa04300310d63e3ea88d509de (patch)
treefa0365618cd7da596651c5d875c136f68abf7f52 /src
parentf47e0c5d47962f472f814174d46258baeaafdf52 (diff)
downloadmerchant-0acefc910ff1b86aa04300310d63e3ea88d509de.tar.gz
merchant-0acefc910ff1b86aa04300310d63e3ea88d509de.tar.bz2
merchant-0acefc910ff1b86aa04300310d63e3ea88d509de.zip
fix memory leaks discovered while valgrinding #6493
Diffstat (limited to 'src')
-rw-r--r--src/backend/taler-merchant-httpd_private-post-orders.c53
1 files changed, 34 insertions, 19 deletions
diff --git a/src/backend/taler-merchant-httpd_private-post-orders.c b/src/backend/taler-merchant-httpd_private-post-orders.c
index 45d766cf..13a21270 100644
--- a/src/backend/taler-merchant-httpd_private-post-orders.c
+++ b/src/backend/taler-merchant-httpd_private-post-orders.c
@@ -377,6 +377,7 @@ execute_order (struct MHD_Connection *connection,
TMH_currency))
{
GNUNET_break_op (0);
+ GNUNET_JSON_parse_free (spec);
return TALER_MHD_reply_with_error (
connection,
MHD_HTTP_BAD_REQUEST,
@@ -387,16 +388,11 @@ execute_order (struct MHD_Connection *connection,
if (wire_transfer_deadline.abs_value_us <
refund_deadline.abs_value_us)
{
- GNUNET_JSON_parse_free (spec);
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "invariant failed: wire_transfer_deadline >= refund_deadline\n");
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "wire_transfer_deadline: %s\n",
- GNUNET_STRINGS_absolute_time_to_string (
- wire_transfer_deadline));
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "refund_deadline: %s\n",
- GNUNET_STRINGS_absolute_time_to_string (refund_deadline));
+ "invariant failed: wire_transfer_deadline %llu >= refund_deadline %llu\n",
+ (unsigned long long) wire_transfer_deadline.abs_value_us,
+ (unsigned long long) refund_deadline.abs_value_us);
+ GNUNET_JSON_parse_free (spec);
return TALER_MHD_reply_with_error (
connection,
MHD_HTTP_BAD_REQUEST,
@@ -429,6 +425,7 @@ execute_order (struct MHD_Connection *connection,
if (0 > qs)
{
TMH_db->rollback (TMH_db->cls);
+ GNUNET_JSON_parse_free (spec);
return qs;
}
else if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs)
@@ -456,10 +453,9 @@ execute_order (struct MHD_Connection *connection,
else
{
/* This request is not idempotent */
- int rv;
+ MHD_RESULT rv;
char *msg;
- GNUNET_JSON_parse_free (spec);
GNUNET_asprintf (&msg,
"order ID `%s' already exists, and the request was not idempotent",
order_id);
@@ -468,6 +464,7 @@ execute_order (struct MHD_Connection *connection,
TALER_EC_PROPOSAL_STORE_DB_ERROR_ALREADY_EXISTS,
msg);
GNUNET_free (msg);
+ GNUNET_JSON_parse_free (spec);
return rv;
}
}
@@ -497,6 +494,7 @@ execute_order (struct MHD_Connection *connection,
if (GNUNET_DB_STATUS_SOFT_ERROR == qs)
{
GNUNET_break (0);
+ GNUNET_JSON_parse_free (spec);
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_PROPOSAL_STORE_DB_ERROR_SOFT,
@@ -514,6 +512,7 @@ execute_order (struct MHD_Connection *connection,
hc->instance->settings.id,
inventory_products[i].product_id,
&pd);
+ GNUNET_JSON_parse_free (spec);
return TALER_MHD_reply_json_pack (connection,
MHD_HTTP_GONE,
"{s:s,s:I,s:I,s:o?}",
@@ -1123,7 +1122,7 @@ TMH_private_post_orders (const struct TMH_RequestHandler *rh,
if (NULL != json_object_get (hc->request_body,
"create_token"))
{
- struct GNUNET_JSON_Specification spec[] = {
+ struct GNUNET_JSON_Specification ispec[] = {
GNUNET_JSON_spec_bool ("create_token",
&create_token),
GNUNET_JSON_spec_end ()
@@ -1133,11 +1132,14 @@ TMH_private_post_orders (const struct TMH_RequestHandler *rh,
(void) rh;
ret = TALER_MHD_parse_json_data (connection,
hc->request_body,
- spec);
+ ispec);
if (GNUNET_OK != ret)
+ {
+ GNUNET_JSON_parse_free (spec);
return (GNUNET_NO == ret)
? MHD_YES
: MHD_NO;
+ }
}
if (create_token)
{
@@ -1157,7 +1159,7 @@ TMH_private_post_orders (const struct TMH_RequestHandler *rh,
if (NULL != json_object_get (hc->request_body,
"refund_delay"))
{
- struct GNUNET_JSON_Specification spec[] = {
+ struct GNUNET_JSON_Specification ispec[] = {
TALER_JSON_spec_relative_time ("refund_delay",
&refund_delay),
GNUNET_JSON_spec_end ()
@@ -1165,11 +1167,14 @@ TMH_private_post_orders (const struct TMH_RequestHandler *rh,
ret = TALER_MHD_parse_json_data (connection,
hc->request_body,
- spec);
+ ispec);
if (GNUNET_OK != ret)
+ {
+ GNUNET_JSON_parse_free (spec);
return (GNUNET_NO == ret)
? MHD_YES
: MHD_NO;
+ }
}
else
{
@@ -1184,10 +1189,13 @@ TMH_private_post_orders (const struct TMH_RequestHandler *rh,
if (NULL != pt)
{
if (! json_is_string (pt))
+ {
+ GNUNET_JSON_parse_free (spec);
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_PARAMETER_MALFORMED,
"payment_target");
+ }
payment_target = json_string_value (pt);
}
}
@@ -1200,10 +1208,13 @@ TMH_private_post_orders (const struct TMH_RequestHandler *rh,
if (NULL != ip)
{
if (! json_is_array (ip))
+ {
+ GNUNET_JSON_parse_free (spec);
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_PARAMETER_MALFORMED,
"inventory_products");
+ }
GNUNET_array_grow (ips,
ips_len,
json_array_size (ip));
@@ -1211,7 +1222,7 @@ TMH_private_post_orders (const struct TMH_RequestHandler *rh,
{
const char *error_name;
unsigned int error_line;
- struct GNUNET_JSON_Specification spec[] = {
+ struct GNUNET_JSON_Specification ispec[] = {
GNUNET_JSON_spec_string ("product_id",
&ips[i].product_id),
GNUNET_JSON_spec_uint32 ("quantity",
@@ -1221,7 +1232,7 @@ TMH_private_post_orders (const struct TMH_RequestHandler *rh,
ret = GNUNET_JSON_parse (json_array_get (ip,
i),
- spec,
+ ispec,
&error_name,
&error_line);
if (GNUNET_OK != ret)
@@ -1235,6 +1246,7 @@ TMH_private_post_orders (const struct TMH_RequestHandler *rh,
i,
error_name,
error_line);
+ GNUNET_JSON_parse_free (spec);
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_PARAMETER_MALFORMED,
@@ -1256,6 +1268,7 @@ TMH_private_post_orders (const struct TMH_RequestHandler *rh,
GNUNET_array_grow (ips,
ips_len,
0);
+ GNUNET_JSON_parse_free (spec);
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_PARAMETER_MALFORMED,
@@ -1268,7 +1281,7 @@ TMH_private_post_orders (const struct TMH_RequestHandler *rh,
{
const char *error_name;
unsigned int error_line;
- struct GNUNET_JSON_Specification spec[] = {
+ struct GNUNET_JSON_Specification ispec[] = {
GNUNET_JSON_spec_fixed_auto ("uuid",
&uuids[i]),
GNUNET_JSON_spec_end ()
@@ -1276,7 +1289,7 @@ TMH_private_post_orders (const struct TMH_RequestHandler *rh,
ret = GNUNET_JSON_parse (json_array_get (uuid,
i),
- spec,
+ ispec,
&error_name,
&error_line);
if (GNUNET_OK != ret)
@@ -1293,6 +1306,7 @@ TMH_private_post_orders (const struct TMH_RequestHandler *rh,
i,
error_name,
error_line);
+ GNUNET_JSON_parse_free (spec);
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_PARAMETER_MALFORMED,
@@ -1321,6 +1335,7 @@ TMH_private_post_orders (const struct TMH_RequestHandler *rh,
GNUNET_array_grow (uuids,
uuids_len,
0);
+ GNUNET_JSON_parse_free (spec);
return res;
}
}