gnunet-svn
[Top][All Lists]
Advanced

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

[taler-exchange] branch master updated: fix misc leaks


From: gnunet
Subject: [taler-exchange] branch master updated: fix misc leaks
Date: Fri, 02 Apr 2021 13:27:24 +0200

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

grothoff pushed a commit to branch master
in repository exchange.

The following commit(s) were added to refs/heads/master by this push:
     new 25fd6dc2 fix misc leaks
25fd6dc2 is described below

commit 25fd6dc25ada684cb52fb680d25d7810d85893fa
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Fri Apr 2 13:27:22 2021 +0200

    fix misc leaks
---
 src/json/json.c | 62 +++++++++++++++++++++++++++++++++++----------------------
 1 file changed, 38 insertions(+), 24 deletions(-)

diff --git a/src/json/json.c b/src/json/json.c
index 2adf7118..fd526a1d 100644
--- a/src/json/json.c
+++ b/src/json/json.c
@@ -449,32 +449,34 @@ parse_path (json_t *obj,
   char *next_path;
   char *bracket;
   json_t *next_obj = NULL;
+  char *next_dot;
 
-  if (NULL != next_id)
-  {
-    bracket = strchr (next_id,
-                      '[');
-    *next_id = '\0';
-    next_id++;
-    next_path = GNUNET_strdup (next_id);
-    char *next_dot = strchr (next_id,
-                             '.');
-    if (NULL != next_dot)
-      *next_dot = '\0';
-  }
-  else
+  if (NULL == next_id)
   {
     cb (cb_cls,
         id,
         prev);
+    GNUNET_free (id);
     return GNUNET_OK;
   }
-
+  bracket = strchr (next_id,
+                    '[');
+  *next_id = '\0';
+  next_id++;
+  next_path = GNUNET_strdup (next_id);
+  next_dot = strchr (next_id,
+                     '.');
+  if (NULL != next_dot)
+    *next_dot = '\0';
   /* If this is the first time this is called, make sure id is "$" */
-  if ((NULL == prev) &&
-      (0 != strcmp (id,
-                    "$")))
+  if ( (NULL == prev) &&
+       (0 != strcmp (id,
+                     "$")))
+  {
+    GNUNET_free (id);
+    GNUNET_free (next_path);
     return GNUNET_SYSERR;
+  }
 
   /* Check for bracketed indices */
   if (NULL != bracket)
@@ -482,7 +484,11 @@ parse_path (json_t *obj,
     char *end_bracket = strchr (bracket,
                                 ']');
     if (NULL == end_bracket)
+    {
+      GNUNET_free (id);
+      GNUNET_free (next_path);
       return GNUNET_SYSERR;
+    }
     *end_bracket = '\0';
 
     *bracket = '\0';
@@ -496,6 +502,7 @@ parse_path (json_t *obj,
       size_t index;
       json_t *value;
       int ret = GNUNET_OK;
+
       json_array_foreach (array, index, value) {
         ret = parse_path (value,
                           obj,
@@ -505,6 +512,7 @@ parse_path (json_t *obj,
         if (GNUNET_OK != ret)
         {
           GNUNET_free (id);
+          GNUNET_free (next_path);
           return ret;
         }
       }
@@ -512,10 +520,15 @@ parse_path (json_t *obj,
     else
     {
       unsigned int index;
+
       if (1 != sscanf (bracket,
                        "%u",
                        &index))
+      {
+        GNUNET_free (id);
+        GNUNET_free (next_path);
         return GNUNET_SYSERR;
+      }
       next_obj = json_array_get (array,
                                  index);
     }
@@ -529,16 +542,17 @@ parse_path (json_t *obj,
 
   if (NULL != next_obj)
   {
-    return parse_path (next_obj,
-                       obj,
-                       next_path,
-                       cb,
-                       cb_cls);
+    int ret = parse_path (next_obj,
+                          obj,
+                          next_path,
+                          cb,
+                          cb_cls);
+    GNUNET_free (id);
+    GNUNET_free (next_path);
+    return ret;
   }
-
   GNUNET_free (id);
   GNUNET_free (next_path);
-
   return GNUNET_OK;
 }
 

-- 
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]