summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOndrej Holy <oholy@redhat.com>2020-12-10 13:22:45 +0100
committerOndrej Holy <oholy@redhat.com>2020-12-10 13:46:58 +0100
commit363ea679e58b98fb98829a20c5d0fb6ed50a0296 (patch)
tree1012444891a80ff2782d2da73ddfc477a7ee3a56
parentdf42290300efe8c67b88c0a8d4b91382a0d9268f (diff)
downloadglib-wip/oholy/gio-info-prevent-criticals.tar.gz
gio-tool-info: Prevent criticals if mount options are not availablewip/oholy/gio-info-prevent-criticals
NULL is valid return value for the g_unix_mount_get_options function because mount options are currently provided only by libmount implementation. However, the gio tool passes the returned value to the g_strescape function without checking, which produces the following critical warning: GLib-CRITICAL **: 13:47:15.294: g_strescape: assertion 'source != NULL' failed Let's add the missing check to prevent the critical warnings.
-rw-r--r--gio/gio-tool-info.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/gio/gio-tool-info.c b/gio/gio-tool-info.c
index 7cf568370..a06263545 100644
--- a/gio/gio-tool-info.c
+++ b/gio/gio-tool-info.c
@@ -182,7 +182,8 @@ show_info (GFile *file, GFileInfo *info)
gchar *root_string = NULL;
gchar *mount;
gchar *fs;
- gchar *options;
+ const gchar *options;
+ gchar *options_string = NULL;
device = g_strescape (g_unix_mount_get_device_path (entry), NULL);
root = g_unix_mount_get_root_path (entry);
@@ -194,16 +195,22 @@ show_info (GFile *file, GFileInfo *info)
}
mount = g_strescape (g_unix_mount_get_mount_path (entry), NULL);
fs = g_strescape (g_unix_mount_get_fs_type (entry), NULL);
- options = g_strescape (g_unix_mount_get_options (entry), NULL);
+
+ options = g_unix_mount_get_options (entry);
+ if (options != NULL)
+ {
+ options_string = g_strescape (options, NULL);
+ }
g_print (_("unix mount: %s%s %s %s %s\n"), device,
- root_string ? root_string : "", mount, fs, options);
+ root_string ? root_string : "", mount, fs,
+ options_string ? options_string : "");
g_free (device);
g_free (root_string);
g_free (mount);
g_free (fs);
- g_free (options);
+ g_free (options_string);
g_unix_mount_free (entry);
}