gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-merchant] branch master updated: fix leaks in /propo


From: gnunet
Subject: [GNUnet-SVN] [taler-merchant] branch master updated: fix leaks in /proposal handling
Date: Tue, 16 Jan 2018 13:49:29 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository merchant.

The following commit(s) were added to refs/heads/master by this push:
     new 0b5bb42  fix leaks in /proposal handling
0b5bb42 is described below

commit 0b5bb420208bfb8b410eb84f7fbe4e7808468e9b
Author: Christian Grothoff <address@hidden>
AuthorDate: Tue Jan 16 13:49:17 2018 +0100

    fix leaks in /proposal handling
---
 src/lib/merchant_api_proposal.c | 36 +++++++++++++++++++-----------------
 src/lib/test_merchant_api.c     |  3 ---
 2 files changed, 19 insertions(+), 20 deletions(-)

diff --git a/src/lib/merchant_api_proposal.c b/src/lib/merchant_api_proposal.c
index 88d902b..9a82f75 100644
--- a/src/lib/merchant_api_proposal.c
+++ b/src/lib/merchant_api_proposal.c
@@ -128,7 +128,8 @@ handle_proposal_finished (void *cls,
   struct TALER_MERCHANT_ProposalOperation *po = cls;
   const char *order_id;
   struct GNUNET_JSON_Specification spec[] = {
-    GNUNET_JSON_spec_string ("order_id", &order_id),
+    GNUNET_JSON_spec_string ("order_id",
+                             &order_id),
     GNUNET_JSON_spec_end()
   };
 
@@ -266,21 +267,25 @@ handle_proposal_lookup_finished (void *cls,
   struct TALER_MerchantSignatureP sig;
   struct GNUNET_HashCode hash;
   struct GNUNET_JSON_Specification spec[] = {
-    GNUNET_JSON_spec_json ("contract_terms", &contract_terms),
-    GNUNET_JSON_spec_fixed_auto ("sig", &sig),
+    GNUNET_JSON_spec_json ("contract_terms",
+                           &contract_terms),
+    GNUNET_JSON_spec_fixed_auto ("sig",
+                                 &sig),
     GNUNET_JSON_spec_end()
   };
 
   if (MHD_HTTP_OK != response_code)
   {
+    char *s;
+
+    s = json_dumps (json,
+                    JSON_COMPACT);
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                "proposal lookup failed with HTTP status code %u\n",
-                (unsigned int) response_code);
-    char *s = json_dumps (json, JSON_COMPACT);
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                "error json: %s\n",
+                "Proposal lookup failed with HTTP status code %u on input 
`%s'\n",
+                (unsigned int) response_code,
                 s);
-    GNUNET_free_non_null (s);
+    if (NULL != s)
+      free (s);
     GNUNET_break_op (0);
     plo->cb (plo->cb_cls,
              response_code,
@@ -298,11 +303,6 @@ handle_proposal_lookup_finished (void *cls,
   {
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                 "proposal lookup failed to parse JSON\n");
-    char *s = json_dumps (json, JSON_COMPACT);
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "proposal json was: %s\n",
-                s);
-    GNUNET_free_non_null (s);
     GNUNET_break_op (0);
     plo->cb (plo->cb_cls,
              0,
@@ -313,11 +313,12 @@ handle_proposal_lookup_finished (void *cls,
     return;
   }
 
-  if (GNUNET_OK != TALER_JSON_hash (contract_terms, &hash))
+  if (GNUNET_OK !=
+      TALER_JSON_hash (contract_terms,
+                       &hash))
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                "proposal lookup failed to hash proposal JSON\n");
     GNUNET_break (0);
+    GNUNET_JSON_parse_free (spec);
     plo->cb (plo->cb_cls,
              0,
              json,
@@ -338,6 +339,7 @@ handle_proposal_lookup_finished (void *cls,
            contract_terms,
            &sig,
            &hash);
+  GNUNET_JSON_parse_free (spec);
   TALER_MERCHANT_proposal_lookup_cancel (plo);
 }
 
diff --git a/src/lib/test_merchant_api.c b/src/lib/test_merchant_api.c
index 219b407..c9d26f4 100644
--- a/src/lib/test_merchant_api.c
+++ b/src/lib/test_merchant_api.c
@@ -3968,7 +3968,6 @@ run (void *cls)
       .details.reserve_status.reserve_reference
         = "create-reserve-1",
       .details.reserve_status.expected_balance = "EUR:0" },
-
     /* Create proposal */
     { .oc = OC_PROPOSAL,
       .label = "create-proposal-1",
@@ -3989,7 +3988,6 @@ run (void *cls)
         \"products\":\
           [ {\"description\":\"ice cream\",\
              \"value\":\"{EUR:5}\"} ] }"},
-
     /* execute simple payment */
     { .oc = OC_PAY,
       .label = "deposit-simple",
@@ -4580,7 +4578,6 @@ run (void *cls)
     /* Check that there are no other unusual transfers */
     { .oc = OC_CHECK_BANK_TRANSFERS_EMPTY,
       .label = "check_bank_empty-11" },
-
     /* end of testcase */
     { .oc = OC_END }
   };

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]