[grilo-plugins] lua-factory: Don't leak list in xml parser



commit b3ab9d059227169e1d57f3157880548f2d33109c
Author: Victor Toso <me victortoso com>
Date:   Wed Feb 22 22:46:47 2017 +0100

    lua-factory: Don't leak list in xml parser
    
    We were calling g_list_free() in the pointer that is the last element
    of the list due g_list_reverse() that was called previously.
    
    1,176 (336 direct, 840 indirect) bytes in 14 blocks are definitely
    lost in loss record 3,289 of 3,315
       at 0x4C2DB9D: malloc (vg_replace_malloc.c:299)
       by 0x4E895B8: g_malloc (in /usr/lib64/libglib-2.0.so.0.5000.3)
       by 0x4EA1B12: g_slice_alloc (in /usr/lib64/libglib-2.0.so.0.5000.3)
       by 0x4E7F9E5: g_list_prepend (in /usr/lib64/libglib-2.0.so.0.5000.3)
       by 0x9377E69: build_table_recursively (lua-xml.c:64)
       by 0x9377FAF: build_table_recursively (lua-xml.c:81)
       by 0x9377FAF: build_table_recursively (lua-xml.c:81)
       by 0x9377FAF: build_table_recursively (lua-xml.c:81)
       by 0x9378182: build_table_from_xml_reader (lua-xml.c:121)
    
    https://bugzilla.gnome.org/show_bug.cgi?id=779444

 src/lua-factory/lua-library/lua-xml.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
---
diff --git a/src/lua-factory/lua-library/lua-xml.c b/src/lua-factory/lua-library/lua-xml.c
index 15d6466..9e1f9b0 100644
--- a/src/lua-factory/lua-library/lua-xml.c
+++ b/src/lua-factory/lua-library/lua-xml.c
@@ -71,6 +71,7 @@ build_table_recursively (lua_State  *L,
     guint len = g_list_length (it);
     guint i;
     xmlNodePtr node;
+    GList *list = it;
 
     if (len == 1) {
       /* Only one node, no array needed */
@@ -94,7 +95,7 @@ build_table_recursively (lua_State  *L,
       }
     }
     lua_settable(L, -3);
-    g_list_free (value);
+    g_list_free (list);
   }
   g_hash_table_destroy (ht);
 }


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