[gnome-software] Do not crash if an icon is set to an empty string
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Do not crash if an icon is set to an empty string
- Date: Mon, 28 Oct 2013 13:17:35 +0000 (UTC)
commit 60551acf07c245a4d7e19325bf0334590336a2b4
Author: Richard Hughes <richard hughsie com>
Date: Mon Oct 28 12:20:10 2013 +0000
Do not crash if an icon is set to an empty string
src/gs-utils.c | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/src/gs-utils.c b/src/gs-utils.c
index c1711ee..edbb5aa 100644
--- a/src/gs-utils.c
+++ b/src/gs-utils.c
@@ -263,7 +263,15 @@ gs_pixbuf_load (const gchar *icon_name, guint icon_size, GError **error)
{
GdkPixbuf *pixbuf = NULL;
- if (icon_name[0] == '/') {
+ g_return_val_if_fail (icon_name != NULL, NULL);
+ g_return_val_if_fail (icon_size > 0, NULL);
+
+ if (icon_name[0] == '\0') {
+ g_set_error_literal (error,
+ GS_PLUGIN_ERROR,
+ GS_PLUGIN_ERROR_FAILED,
+ "Icon name not specified");
+ } else if (icon_name[0] == '/') {
pixbuf = gdk_pixbuf_new_from_file_at_size (icon_name,
icon_size,
icon_size,
@@ -279,7 +287,7 @@ gs_pixbuf_load (const gchar *icon_name, guint icon_size, GError **error)
g_set_error (error,
GS_PLUGIN_ERROR,
GS_PLUGIN_ERROR_FAILED,
- "Failed to load icon %s", icon_name);
+ "Failed to load icon '%s'", icon_name);
}
return pixbuf;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]