file filter: Be save against NULL
authorMatthias Clasen <mclasen@redhat.com>
Mon, 8 May 2017 20:35:53 +0000 (16:35 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 8 May 2017 20:39:20 +0000 (16:39 -0400)
g_content_type_from_mime_type may return NULL, deal with that.

https://bugzilla.gnome.org/show_bug.cgi?id=782180

gtk/gtkfilefilter.c

index e86f2d830413bc0ba782f74cb9d127c9a168f398..5339ac7f38ee6cde19dd91c8c9a20c33f51be590 100644 (file)
@@ -673,19 +673,21 @@ gtk_file_filter_filter (GtkFileFilter           *filter,
       switch (rule->type)
        {
        case FILTER_RULE_MIME_TYPE:
-      if (filter_info->mime_type != NULL)
-        {
-          gchar *filter_content_type, *rule_content_type;
-          gboolean match;
-
-          filter_content_type = g_content_type_from_mime_type (filter_info->mime_type);
-          rule_content_type = g_content_type_from_mime_type (rule->u.mime_type);
-          match = g_content_type_is_a (filter_content_type, rule_content_type);
-          g_free (filter_content_type);
-          g_free (rule_content_type);
-
-          if (match)
-            return TRUE;
+          if (filter_info->mime_type != NULL)
+            {
+              gchar *filter_content_type, *rule_content_type;
+              gboolean match;
+
+              filter_content_type = g_content_type_from_mime_type (filter_info->mime_type);
+              rule_content_type = g_content_type_from_mime_type (rule->u.mime_type);
+              match = filter_content_type != NULL &&
+                      rule_content_type != NULL &&
+                      g_content_type_is_a (filter_content_type, rule_content_type);
+              g_free (filter_content_type);
+              g_free (rule_content_type);
+
+              if (match)
+                return TRUE;
         }
          break;
        case FILTER_RULE_PATTERN: