gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] branch master updated: fix memory leaks discovered whil


From: gnunet
Subject: [taler-merchant] branch master updated: fix memory leaks discovered while valgrinding #6493
Date: Tue, 25 Aug 2020 11:08:46 +0200

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 0acefc9  fix memory leaks discovered while valgrinding #6493
0acefc9 is described below

commit 0acefc910ff1b86aa04300310d63e3ea88d509de
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Tue Aug 25 11:08:43 2020 +0200

    fix memory leaks discovered while valgrinding #6493
---
 .../taler-merchant-httpd_private-post-orders.c     | 53 ++++++++++++++--------
 1 file 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 45d766c..13a2127 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;
   }
 }

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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