[yelp] Check whether parser is null before dereferencing it



commit 6b05dd2a96f210ea46d057c2c571987adceb1e89
Author: Tomas Popela <tpopela redhat com>
Date:   Mon Jul 23 11:15:10 2018 +0200

    Check whether parser is null before dereferencing it
    
    yelp-3.28.1/libyelp/yelp-man-parser.c:445: var_compare_op: Comparing "parser" to null implies that 
"parser" might be null.
    yelp-3.28.1/libyelp/yelp-man-parser.c:449: var_deref_op: Dereferencing null pointer "parser".

 libyelp/yelp-man-parser.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/libyelp/yelp-man-parser.c b/libyelp/yelp-man-parser.c
index 46073a2e..8d097820 100644
--- a/libyelp/yelp-man-parser.c
+++ b/libyelp/yelp-man-parser.c
@@ -442,10 +442,12 @@ void
 yelp_man_parser_free (YelpManParser *parser)
 {
     guint k;
-    if (parser) {
-        for (k=0; k<MAN_FONTS; k++)
-            g_free (parser->font_registers[k]);
-    }
+
+    if (parser == NULL)
+        return;
+
+    for (k=0; k<MAN_FONTS; k++)
+        g_free (parser->font_registers[k]);
     g_string_free (parser->accumulator, TRUE);
     g_free (parser->title_str);
     g_free (parser->section);


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