gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [gnunet] branch master updated: REST/NAMESTORE: fix memleak


From: gnunet
Subject: [GNUnet-SVN] [gnunet] branch master updated: REST/NAMESTORE: fix memleak
Date: Tue, 30 Apr 2019 17:40:53 +0200

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

martin-schanzenbach pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new b0b190fb5 REST/NAMESTORE: fix memleak
b0b190fb5 is described below

commit b0b190fb57a4bb5eb4f9c5b1da6a4311496112e1
Author: Schanzenbach, Martin <address@hidden>
AuthorDate: Tue Apr 30 17:40:36 2019 +0200

    REST/NAMESTORE: fix memleak
---
 src/json/json_gnsrecord.c             | 46 +++++++++++++++++------------------
 src/namestore/plugin_rest_namestore.c |  1 +
 2 files changed, 24 insertions(+), 23 deletions(-)

diff --git a/src/json/json_gnsrecord.c b/src/json/json_gnsrecord.c
index eef9e0e79..2ba4da591 100644
--- a/src/json/json_gnsrecord.c
+++ b/src/json/json_gnsrecord.c
@@ -48,24 +48,19 @@ struct GnsRecordInfo
 static void
 cleanup_recordinfo (struct GnsRecordInfo *gnsrecord_info)
 {
-  if (NULL != gnsrecord_info)
+  if (NULL != *(gnsrecord_info->rd))
   {
-    if (NULL != *(gnsrecord_info->rd))
+    for (int i = 0; i < *(gnsrecord_info->rd_count); i++)
     {
-      for (int i = 0; i < *(gnsrecord_info->rd_count); i++)
-      {
-        if (NULL != (*(gnsrecord_info->rd))[i].data)
-          GNUNET_free ((char *) (*(gnsrecord_info->rd))[i].data);
-      }
-      GNUNET_free (*(gnsrecord_info->rd));
-      *(gnsrecord_info->rd) = NULL;
+      if (NULL != (*(gnsrecord_info->rd))[i].data)
+        GNUNET_free ((char *) (*(gnsrecord_info->rd))[i].data);
     }
-    if (NULL != *(gnsrecord_info->name))
-      GNUNET_free (*(gnsrecord_info->name));
-    *(gnsrecord_info->name) = NULL;
-    GNUNET_free (gnsrecord_info);
+    GNUNET_free (*(gnsrecord_info->rd));
+    *(gnsrecord_info->rd) = NULL;
   }
-
+  if (NULL != *(gnsrecord_info->name))
+    GNUNET_free (*(gnsrecord_info->name));
+  *(gnsrecord_info->name) = NULL;
 }
 
 
@@ -210,7 +205,12 @@ parse_gnsrecordobject (void *cls,
   }
   gnsrecord_info = (struct GnsRecordInfo *) spec->ptr;
   *(gnsrecord_info->name) = GNUNET_strdup (name);
-  return parse_record_data (gnsrecord_info, data);
+  if (GNUNET_OK != parse_record_data (gnsrecord_info, data))
+  {
+    cleanup_recordinfo (gnsrecord_info);
+    return GNUNET_SYSERR;
+  }
+  return GNUNET_OK;
 }
 
 
@@ -224,7 +224,7 @@ static void
 clean_gnsrecordobject (void *cls, struct GNUNET_JSON_Specification *spec)
 {
   struct GnsRecordInfo *gnsrecord_info = (struct GnsRecordInfo *) spec->ptr;
-  cleanup_recordinfo (gnsrecord_info);
+  GNUNET_free (gnsrecord_info);
 }
 
 
@@ -244,12 +244,12 @@ GNUNET_JSON_spec_gnsrecord (struct GNUNET_GNSRECORD_Data 
**rd,
   gnsrecord_info->name = name;
   gnsrecord_info->rd_count = rd_count;
   struct GNUNET_JSON_Specification ret = {.parser = &parse_gnsrecordobject,
-                                          .cleaner = &clean_gnsrecordobject,
-                                          .cls = NULL,
-                                          .field = NULL,
-                                          .ptr = (struct GnsRecordInfo *)
-                                            gnsrecord_info,
-                                          .ptr_size = 0,
-                                          .size_ptr = NULL};
+    .cleaner = &clean_gnsrecordobject,
+    .cls = NULL,
+    .field = NULL,
+    .ptr = (struct GnsRecordInfo *)
+      gnsrecord_info,
+    .ptr_size = 0,
+    .size_ptr = NULL};
   return ret;
 }
diff --git a/src/namestore/plugin_rest_namestore.c 
b/src/namestore/plugin_rest_namestore.c
index 39b21c233..1d8c180fb 100644
--- a/src/namestore/plugin_rest_namestore.c
+++ b/src/namestore/plugin_rest_namestore.c
@@ -628,6 +628,7 @@ namestore_add (struct GNUNET_REST_RequestHandle *con_handle,
     json_decref (data_js);
     return;
   }
+  GNUNET_JSON_parse_free (gnsspec);
   if (0 >= strlen (handle->record_name))
   {
     handle->emsg = GNUNET_strdup (GNUNET_REST_NAMESTORE_INVALID_DATA);

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



reply via email to

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