[gtk+] GtkIconTheme: Make suffix_from_name NULL-safe
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] GtkIconTheme: Make suffix_from_name NULL-safe
- Date: Fri, 5 Sep 2014 17:16:19 +0000 (UTC)
commit 162990394387e744122273cc6d473b45b133e158
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Sep 5 13:15:14 2014 -0400
GtkIconTheme: Make suffix_from_name NULL-safe
This can happen sometimes with GFileIcons that are
not representable as a local path. Better not to crash
in this case.
gtk/gtkicontheme.c | 25 +++++++++++++------------
1 files changed, 13 insertions(+), 12 deletions(-)
---
diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c
index f4fc82f..8ac6dd6 100644
--- a/gtk/gtkicontheme.c
+++ b/gtk/gtkicontheme.c
@@ -2840,18 +2840,19 @@ string_from_suffix (IconSuffix suffix)
static IconSuffix
suffix_from_name (const gchar *name)
{
- IconSuffix retval;
-
- if (g_str_has_suffix (name, ".symbolic.png"))
- retval = ICON_SUFFIX_SYMBOLIC_PNG;
- else if (g_str_has_suffix (name, ".png"))
- retval = ICON_SUFFIX_PNG;
- else if (g_str_has_suffix (name, ".svg"))
- retval = ICON_SUFFIX_SVG;
- else if (g_str_has_suffix (name, ".xpm"))
- retval = ICON_SUFFIX_XPM;
- else
- retval = ICON_SUFFIX_NONE;
+ IconSuffix retval = ICON_SUFFIX_NONE;
+
+ if (name != NULL)
+ {
+ if (g_str_has_suffix (name, ".symbolic.png"))
+ retval = ICON_SUFFIX_SYMBOLIC_PNG;
+ else if (g_str_has_suffix (name, ".png"))
+ retval = ICON_SUFFIX_PNG;
+ else if (g_str_has_suffix (name, ".svg"))
+ retval = ICON_SUFFIX_SVG;
+ else if (g_str_has_suffix (name, ".xpm"))
+ retval = ICON_SUFFIX_XPM;
+ }
return retval;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]