Some fixes found by coverity for things used before a null check
authorMikael Magnusson <mikachu@gmail.com>
Tue, 28 Oct 2014 04:20:10 +0000 (05:20 +0100)
committerMikael Magnusson <mikachu@gmail.com>
Tue, 28 Oct 2014 04:42:28 +0000 (05:42 +0100)
In the second case, we actually check the wrong variable.

obrender/image.c
obt/xml.c

index 8ff9bf106b0ef204b339a77527dafcc613934ea8..fb5f40bc1e17703814d9840f8e438acf9de29a40 100644 (file)
@@ -243,7 +243,7 @@ RrImageSet* RrImageSetMergeSets(RrImageSet *b, RrImageSet *a)
     gint n_original, n_resized, tmp;
     GSList *it;
 
-    const gint max_resized = a->cache->max_resized_saved;
+    gint max_resized;
 
     if (!a)
         return b;
@@ -251,7 +251,6 @@ RrImageSet* RrImageSetMergeSets(RrImageSet *b, RrImageSet *a)
         return a;
     if (a == b)
         return b;
-
     /* the original and resized picture lists in an RrImageSet are kept ordered
        as newest to oldest.  we don't have timestamps for them, so we cannot
        preserve this in the merged RrImageSet exactly.  a decent approximation,
@@ -264,6 +263,8 @@ RrImageSet* RrImageSetMergeSets(RrImageSet *b, RrImageSet *a)
 
     g_assert(b->cache == a->cache);
 
+    max_resized = a->cache->max_resized_saved;
+
     a_i = b_i = merged_i = 0;
     n_original = a->n_original + b->n_original;
     original = g_new(RrImagePic*, n_original);
index 223ad02b239df6dd0e173e7fb536e01b1027127a..f200ae7543f53831962e26e054c011df48456802 100644 (file)
--- a/obt/xml.c
+++ b/obt/xml.c
@@ -281,7 +281,7 @@ gboolean obt_xml_load_mem(ObtXmlInst *i,
     xmlResetLastError();
 
     i->doc = xmlParseMemory(data, len);
-    if (i) {
+    if (i->doc) {
         i->root = xmlDocGetRootElement(i->doc);
         if (!i->root) {
             xmlFreeDoc(i->doc);