summaryrefslogtreecommitdiff
path: root/src/backend/taler-merchant-httpd_proposal.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2018-01-16 12:39:46 +0100
committerChristian Grothoff <christian@grothoff.org>2018-01-16 12:39:46 +0100
commit0d50ba20bb0746e1e33e7e4d5f050110044310c1 (patch)
treefd9118781fa5a28632892bdb2b09aa50db166d1d /src/backend/taler-merchant-httpd_proposal.c
parent55cd81c3d60aaaeeca8eae3825a5f91be1a81a16 (diff)
downloadmerchant-0d50ba20bb0746e1e33e7e4d5f050110044310c1.tar.gz
merchant-0d50ba20bb0746e1e33e7e4d5f050110044310c1.tar.bz2
merchant-0d50ba20bb0746e1e33e7e4d5f050110044310c1.zip
fix a few memory leaks
Diffstat (limited to 'src/backend/taler-merchant-httpd_proposal.c')
-rw-r--r--src/backend/taler-merchant-httpd_proposal.c53
1 files changed, 40 insertions, 13 deletions
diff --git a/src/backend/taler-merchant-httpd_proposal.c b/src/backend/taler-merchant-httpd_proposal.c
index 278a28e7..31e3fb39 100644
--- a/src/backend/taler-merchant-httpd_proposal.c
+++ b/src/backend/taler-merchant-httpd_proposal.c
@@ -156,6 +156,7 @@ proposal_put (struct MHD_Connection *connection,
GNUNET_JSON_spec_end ()
};
enum GNUNET_DB_QueryStatus qs;
+ const char *instance;
/* Add order_id if it doesn't exist. */
if (NULL ==
@@ -246,39 +247,65 @@ proposal_put (struct MHD_Connection *connection,
json_integer ((json_int_t) default_wire_fee_amortization));
}
- if (NULL == json_object_get (order, "pay_url"))
+ if (NULL == json_object_get (order,
+ "pay_url"))
{
char *url;
- url = TMH_make_absolute_backend_url (connection, "pay", NULL);
- json_object_set_new (order, "pay_url", json_string (url));
+
+ url = TMH_make_absolute_backend_url (connection,
+ "pay",
+ NULL);
+ json_object_set_new (order,
+ "pay_url",
+ json_string (url));
+ GNUNET_free (url);
}
- if (NULL == json_object_get (order, "products"))
+ if (NULL == json_object_get (order,
+ "products"))
{
// FIXME: When there is no explicit product,
// should we create a singleton product list?
- json_object_set_new (order, "products", json_array ());
+ json_object_set_new (order,
+ "products",
+ json_array ());
}
- const char *instance = json_string_value (json_object_get (order, "instance"));
+ instance = json_string_value (json_object_get (order,
+ "instance"));
if (NULL != instance)
{
// The frontend either fully specifieds the "merchant" field, or just gives
// the backend the "instance" name and lets it fill out.
struct MerchantInstance *mi = TMH_lookup_instance (instance);
+ json_t *merchant;
+
if (NULL == mi)
{
return TMH_RESPONSE_reply_internal_error (connection,
TALER_EC_PROPOSAL_ORDER_PARSE_ERROR,
"merchant instance not found");
}
- json_t *merchant = json_object ();
- json_object_set_new (merchant, "instance", json_string (instance));
- json_object_set_new (merchant, "name", json_string (mi->name));
- json_object_set_new (merchant, "jurisdiction", json_string ("none"));
- json_object_set_new (merchant, "address", json_string ("none"));
- json_object_set_new (order, "merchant", merchant);
- json_object_del (order, "instance");
+ merchant = json_object ();
+ /* FIXME: should the 'instance' field really be included in the
+ contract? This is really internal to the business! */
+ json_object_set_new (merchant,
+ "instance",
+ json_string (instance));
+ json_object_set_new (merchant,
+ "name",
+ json_string (mi->name));
+ json_object_set_new (merchant,
+ "jurisdiction",
+ json_string ("none"));
+ json_object_set_new (merchant,
+ "address",
+ json_string ("none"));
+ json_object_set_new (order,
+ "merchant",
+ merchant);
+ json_object_del (order,
+ "instance");
}
/* extract fields we need to sign separately */