[json-glib: 1/3] json-parser: Fix a memory leak on two error handling paths



commit 96d591b5708ef9dfb4c02d2ae39b891f903d8a58
Author: Philip Withnall <withnall endlessm com>
Date:   Fri Dec 15 15:28:09 2017 +0000

    json-parser: Fix a memory leak on two error handling paths
    
    Small leak. With some additional fixes to the tests themselves, this
    makes all the tests run valgrind-clean. (See the following commit.)
    
    Signed-off-by: Philip Withnall <withnall endlessm com>
    
    https://gitlab.gnome.org/GNOME/json-glib/issues/30

 json-glib/json-parser.c | 2 ++
 1 file changed, 2 insertions(+)
---
diff --git a/json-glib/json-parser.c b/json-glib/json-parser.c
index bdb7123..015c861 100644
--- a/json-glib/json-parser.c
+++ b/json-glib/json-parser.c
@@ -746,6 +746,7 @@ json_parse_object (JsonParser   *parser,
             {
               priv->error_code = JSON_PARSER_ERROR_TRAILING_COMMA;
 
+              g_free (name);
               json_object_unref (object);
               json_node_unref (member);
               json_node_unref (priv->current_node);
@@ -758,6 +759,7 @@ json_parse_object (JsonParser   *parser,
         {
           priv->error_code = JSON_PARSER_ERROR_MISSING_COMMA;
 
+          g_free (name);
           json_object_unref (object);
           json_node_unref (member);
           json_node_unref (priv->current_node);


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