[devhelp] parser: add missing dh_link_ref() when storing link in the GNode

commit 0bba90813b4ede88698979b75ada84fed0ea629a
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Fri May 12 07:50:12 2017 +0200

    parser: add missing dh_link_ref() when storing link in the GNode
    I've checked with valgrind, and indeed there was this:
    Invalid read of size 4
       at 0x4E4A288: dh_link_unref (in /home/seb/jhbuild/lib/libdevhelp-3.so.3.0.0)
       by 0xB989291: g_list_foreach (glist.c:1005)
       by 0xB98883B: g_list_free_full (glist.c:220)
       by 0x4E43F15: dh_book_finalize (in /home/seb/jhbuild/lib/libdevhelp-3.so.3.0.0)
    (in dh_book_finalize() the GNode tree is freed first, and then the GList
    of keywords).
    This is now fixed.
    This commit also makes the code in parser_start_node_book() consistent
    with the other functions.

 src/dh-parser.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/dh-parser.c b/src/dh-parser.c
index 0c158f3..47da5ed 100644
--- a/src/dh-parser.c
+++ b/src/dh-parser.c
@@ -172,13 +172,12 @@ parser_start_node_book (DhParser             *parser,
         g_free (base);
-        *parser->keywords = g_list_prepend (*parser->keywords, dh_link_ref (link));
+        *parser->keywords = g_list_prepend (*parser->keywords, link);
         g_assert (parser->book_node == NULL);
         parser->book_node = g_node_new (dh_link_ref (link));
         *parser->book_tree = parser->book_node;
         parser->parent = parser->book_node;
-        dh_link_unref (link);
 static void
@@ -237,8 +236,7 @@ parser_start_node_chapter (DhParser             *parser,
         *parser->keywords = g_list_prepend (*parser->keywords, link);
-        /* FIXME probably need to ref the link here */
-        node = g_node_new (link);
+        node = g_node_new (dh_link_ref (link));
         g_node_prepend (parser->parent, node);
         parser->parent = node;

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