[yelp] Check whether the index variable is valid before dereferencing it



commit 45292455a213671d2345fc15a87bb4810f0d43c8
Author: Tomas Popela <tpopela redhat com>
Date:   Mon Jul 23 10:09:43 2018 +0200

    Check whether the index variable is valid before dereferencing it
    
    yelp-3.28.1/libyelp/yelp-docbook-document.c:1058: check_after_deref: Null-checking "index" suggests that 
it may be null, but it has already been dereferenced on all paths leading to the check.
    yelp-3.28.1/libyelp/yelp-docbook-document.c:1026: deref_ptr: Directly dereferencing pointer "index".
    yelp-3.28.1/libyelp/yelp-docbook-document.c:1054: deref_ptr: Directly dereferencing pointer "index".
     1052|       if (filename != NULL)
     1053|           g_free (filename);
     1054|->     if (index->doc != NULL)
     1055|           xmlFreeDoc (index->doc);
     1056|       if (index->doc_uri != NULL)

 libyelp/yelp-docbook-document.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/libyelp/yelp-docbook-document.c b/libyelp/yelp-docbook-document.c
index 9557427f..62f40611 100644
--- a/libyelp/yelp-docbook-document.c
+++ b/libyelp/yelp-docbook-document.c
@@ -1129,12 +1129,13 @@ docbook_index_threaded (YelpDocbookDocument *docbook)
         g_object_unref (file);
     if (filename != NULL)
         g_free (filename);
-    if (index->doc != NULL)
-        xmlFreeDoc (index->doc);
-    if (index->doc_uri != NULL)
-        g_free (index->doc_uri);
-    if (index != NULL)
+    if (index != NULL) {
+        if (index->doc != NULL)
+            xmlFreeDoc (index->doc);
+        if (index->doc_uri != NULL)
+            g_free (index->doc_uri);
         g_free (index);
+    }
     if (parserCtxt != NULL)
         xmlFreeParserCtxt (parserCtxt);
 


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