From 596249266db2fa2bee66ca0b0eef443b080738d7 Mon Sep 17 00:00:00 2001 From: Alexander Schwinn 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 fbe7f8649..100a4d3eb 100644 --- a/thunar/thunar-file.c +++ b/thunar/thunar-file.c @@ -1005,7 +1005,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 0544593e7..b6bf589ea 100644 --- a/thunar/thunar-gio-extensions.c +++ b/thunar/thunar-gio-extensions.c @@ -327,7 +327,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); @@ -372,7 +372,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); }