summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVictor Kareh <[email protected]>2026-02-11 16:10:38 -0500
committerVictor Kareh <[email protected]>2026-02-11 16:10:38 -0500
commit92146417a281706d2312912c0d76c5da96ef16ea (patch)
tree3c547144b7ca77864fca4d756a4ec6bcb4c97fe7 /src
parent034677b0c5bf9b37c22a6d2d52f8761c2364857d (diff)
downloadeom-add-null-checks-when-missing-attributes.tar.bz2
eom-add-null-checks-when-missing-attributes.tar.xz
Add null checks for content type with remote filesadd-null-checks-when-missing-attributes
Adds NULL checks when content-type attributes are missing from GVFS backends. This prevents a crash when opening images from remote filesystems where both standard and fast content-type attributes are missing. Fixes #366
Diffstat (limited to 'src')
-rw-r--r--src/eom-list-store.c3
-rw-r--r--src/eom-metadata-sidebar.c6
-rw-r--r--src/eom-properties-dialog.c6
-rw-r--r--src/eom-window.c9
4 files changed, 21 insertions, 3 deletions
diff --git a/src/eom-list-store.c b/src/eom-list-store.c
index 9336614..ae7f83b 100644
--- a/src/eom-list-store.c
+++ b/src/eom-list-store.c
@@ -477,7 +477,8 @@ directory_visit (GFile *directory,
if (!g_str_has_prefix (name, ".")) {
/* We support opening any image type, so let eom to add any images in the current directory to the store */
- if (g_content_type_is_mime_type (mime_type, "image/*") || eom_image_is_supported_mime_type (mime_type)) {
+ if (mime_type != NULL &&
+ (g_content_type_is_mime_type (mime_type, "image/*") || eom_image_is_supported_mime_type (mime_type))) {
load_uri = TRUE;
}
}
diff --git a/src/eom-metadata-sidebar.c b/src/eom-metadata-sidebar.c
index 2dbde74..9d70b0a 100644
--- a/src/eom-metadata-sidebar.c
+++ b/src/eom-metadata-sidebar.c
@@ -167,7 +167,11 @@ eom_metadata_sidebar_update_general_section (EomMetadataSidebar *sidebar)
const gchar *mime_str;
mime_str = eom_util_get_content_type_with_fallback (file_info);
- str = g_content_type_get_description (mime_str);
+ if (mime_str != NULL) {
+ str = g_content_type_get_description (mime_str);
+ } else {
+ str = g_strdup (_("Unknown"));
+ }
g_object_unref (file_info);
}
gtk_label_set_text (GTK_LABEL (priv->type_label), str);
diff --git a/src/eom-properties-dialog.c b/src/eom-properties-dialog.c
index 480b3f7..5c13261 100644
--- a/src/eom-properties-dialog.c
+++ b/src/eom-properties-dialog.c
@@ -180,7 +180,11 @@ pd_update_general_tab (EomPropertiesDialog *prop_dlg,
type_str = g_strdup (_("Unknown"));
} else {
mime_str = eom_util_get_content_type_with_fallback (file_info);
- type_str = g_content_type_get_description (mime_str);
+ if (mime_str != NULL) {
+ type_str = g_content_type_get_description (mime_str);
+ } else {
+ type_str = g_strdup (_("Unknown"));
+ }
g_object_unref (file_info);
}
diff --git a/src/eom-window.c b/src/eom-window.c
index e24738b..2a3de8e 100644
--- a/src/eom-window.c
+++ b/src/eom-window.c
@@ -748,6 +748,15 @@ add_file_to_recent_files (GFile *file)
recent_data->display_name = NULL;
recent_data->description = NULL;
recent_data->mime_type = (gchar *) eom_util_get_content_type_with_fallback (file_info);
+
+ /* mime_type is required by GTK, so bail out if we couldn't determine it */
+ if (recent_data->mime_type == NULL) {
+ g_slice_free (GtkRecentData, recent_data);
+ g_free (text_uri);
+ g_object_unref (file_info);
+ return FALSE;
+ }
+
recent_data->app_name = EOM_RECENT_FILES_APP_NAME;
recent_data->app_exec = g_strjoin(" ", g_get_prgname (), "%u", NULL);
recent_data->groups = groups;