From af44cb145116cf164802d51f1a41744f83cc8d71 Mon Sep 17 00:00:00 2001
From: Alexander Schwinn <alexxcons@xfce.org>
Date: Wed, 19 Jan 2022 22:53:21 +0100
Subject: [PATCH] Add NULL checks to prevent crash on malformed bookmark URI
 (Issue #716)

---
 thunar/thunar-file.c           | 2 +-
 thunar/thunar-gio-extensions.c | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c
index c73a9b08e..7ec1cbbb9 100644
--- a/thunar/thunar-file.c
+++ b/thunar/thunar-file.c
@@ -1015,7 +1015,7 @@ thunar_file_info_reload (ThunarFile   *file,
   _thunar_assert (file->basename != NULL);
 
   /* problematic files with content type reading */
-  if (strcmp (file->basename, "kmsg") == 0
+  if (g_strcmp0 (file->basename, "kmsg") == 0
       && g_file_is_native (file->gfile))
     {
       path = g_file_get_path (file->gfile);
diff --git a/thunar/thunar-gio-extensions.c b/thunar/thunar-gio-extensions.c
index b9019a22b..a126f4ffa 100644
--- a/thunar/thunar-gio-extensions.c
+++ b/thunar/thunar-gio-extensions.c
@@ -466,7 +466,7 @@ thunar_g_file_get_display_name_remote (GFile *mount_point)
       scheme = g_file_get_uri_scheme (mount_point);
       parse_name = g_file_get_parse_name (mount_point);
 
-      if (g_str_has_prefix (parse_name, scheme))
+      if (scheme != NULL && g_str_has_prefix (parse_name, scheme))
         {
           /* extract the hostname */
           p = parse_name + strlen (scheme);
@@ -511,7 +511,8 @@ thunar_g_file_get_display_name_remote (GFile *mount_point)
           g_free (hostname);
         }
 
-      g_free (scheme);
+      if (scheme != NULL)
+        g_free (scheme);
       g_free (parse_name);
     }
 
-- 
GitLab