From c15683e8ff791880935d0d090f8282da53084a69 Mon Sep 17 00:00:00 2001 From: Rodney Dawes Date: Sat, 26 Feb 2005 19:00:19 +0000 Subject: [PATCH] If the filename is not encoded in UTF-8, we just ignore it for now to 2005-02-26 Rodney Dawes * gnome-wp-capplet.c (gnome_wp_add_image): If the filename is not encoded in UTF-8, we just ignore it for now to avoid crashing * gnome-wp-xml.c (gnome_wp_xml_load_xml): Check to make sure that the filename and name tags that we read in, aren't NULL If the filename we read in is NULL, free the item, and continue on Fixes #146130 #146645 (resolving these as dups of #168604 ) Fixes #159441 --- capplets/background/ChangeLog | 12 ++++++++++++ capplets/background/gnome-wp-capplet.c | 3 +++ capplets/background/gnome-wp-xml.c | 18 ++++++++++++------ 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/capplets/background/ChangeLog b/capplets/background/ChangeLog index 22ee357ba..a19f3b73e 100644 --- a/capplets/background/ChangeLog +++ b/capplets/background/ChangeLog @@ -1,3 +1,15 @@ +2005-02-26 Rodney Dawes + + * gnome-wp-capplet.c (gnome_wp_add_image): If the filename is not + encoded in UTF-8, we just ignore it for now to avoid crashing + + * gnome-wp-xml.c (gnome_wp_xml_load_xml): Check to make sure that the + filename and name tags that we read in, aren't NULL + If the filename we read in is NULL, free the item, and continue on + + Fixes #146130 #146645 (resolving these as dups of #168604 ) + Fixes #159441 + 2005-02-06 Rodney Dawes * gnome-wp-capplet.c (wallpaper_properties_init): Force using the gtk+ diff --git a/capplets/background/gnome-wp-capplet.c b/capplets/background/gnome-wp-capplet.c index 246c7a577..018c5dd62 100644 --- a/capplets/background/gnome-wp-capplet.c +++ b/capplets/background/gnome-wp-capplet.c @@ -93,6 +93,9 @@ static GnomeWPItem * gnome_wp_add_image (GnomeWPCapplet * capplet, const gchar * filename) { GnomeWPItem * item; + if (!g_utf8_validate (filename, -1, NULL)) + return NULL; + item = g_hash_table_lookup (capplet->wphash, filename); if (item != NULL) { if (item->deleted) { diff --git a/capplets/background/gnome-wp-xml.c b/capplets/background/gnome-wp-xml.c index 3a8c45239..14d73fa2c 100644 --- a/capplets/background/gnome-wp-xml.c +++ b/capplets/background/gnome-wp-xml.c @@ -118,13 +118,13 @@ static void gnome_wp_xml_load_xml (GnomeWPCapplet * capplet, for (wpa = list->children; wpa != NULL; wpa = wpa->next) { if (!strcmp (wpa->name, "filename")) { - if (wpa->last != NULL) { + if (wpa->last != NULL && wpa->last->content != NULL) { wp->filename = g_strdup (g_strstrip (wpa->last->content)); } else { break; } } else if (!strcmp (wpa->name, "name")) { - if (wpa->last != NULL) { + if (wpa->last != NULL && wpa->last->content != NULL) { nodelang = xmlNodeGetLang (wpa->last); if (wp->name == NULL && nodelang == NULL) { @@ -138,6 +138,8 @@ static void gnome_wp_xml_load_xml (GnomeWPCapplet * capplet, } xmlFree (nodelang); + } else { + break; } } else if (!strcmp (wpa->name, "imguri")) { if (wpa->last != NULL) { @@ -169,11 +171,15 @@ static void gnome_wp_xml_load_xml (GnomeWPCapplet * capplet, } } - /* Make sure we don't already have this one */ - item = g_hash_table_lookup (capplet->wphash, wp->filename); + /* Make sure we don't already have this one and that filename exists */ + if (wp->filename != NULL) { + item = g_hash_table_lookup (capplet->wphash, wp->filename); - if (item != NULL) { - gnome_wp_item_free (wp); + if (item != NULL) { + gnome_wp_item_free (wp); + continue; + } + } else { continue; }