diff src/aosd/aosd_trigger.c @ 766:53f63f43663f trunk

[svn] - extra check with g_utf8_validate to avoid the osd crash when a non-utf8 string survives the str_to_utf8 conversion
author giacomo
date Thu, 01 Mar 2007 18:22:51 -0800
parents 40fb4189fa88
children 9794a5487524
line wrap: on
line diff
--- a/src/aosd/aosd_trigger.c	Thu Mar 01 06:31:20 2007 -0800
+++ b/src/aosd/aosd_trigger.c	Thu Mar 01 18:22:51 2007 -0800
@@ -164,10 +164,13 @@
       title = playlist_get_songtitle(active, pos);
     }
     gchar *utf8_title = str_to_utf8( title );
-    gchar *utf8_title_markup = g_markup_printf_escaped(
-      "<span font_desc='%s'>%s</span>" , global_config->osd->text.fonts_name[0] , utf8_title );
-    aosd_display( utf8_title_markup , global_config->osd , FALSE );
-    g_free( utf8_title_markup );
+    if ( g_utf8_validate( utf8_title , -1 , NULL ) == TRUE )
+    {
+      gchar *utf8_title_markup = g_markup_printf_escaped(
+        "<span font_desc='%s'>%s</span>" , global_config->osd->text.fonts_name[0] , utf8_title );
+      aosd_display( utf8_title_markup , global_config->osd , FALSE );
+      g_free( utf8_title_markup );
+    }
     g_free( utf8_title );
     g_free( title );
   }
@@ -228,10 +231,13 @@
         {
           /* string formatting is done here a.t.m. - TODO - improve this area */
           gchar *utf8_title = str_to_utf8( pl_entry->title );
-          gchar *utf8_title_markup = g_markup_printf_escaped(
-            "<span font_desc='%s'>%s</span>" , global_config->osd->text.fonts_name[0] , utf8_title );
-          aosd_display( utf8_title_markup , global_config->osd , FALSE );
-          g_free( utf8_title_markup );
+          if ( g_utf8_validate( utf8_title , -1 , NULL ) == TRUE )
+          {
+            gchar *utf8_title_markup = g_markup_printf_escaped(
+              "<span font_desc='%s'>%s</span>" , global_config->osd->text.fonts_name[0] , utf8_title );
+            aosd_display( utf8_title_markup , global_config->osd , FALSE );
+            g_free( utf8_title_markup );
+          }
           g_free( utf8_title );
           g_free( prevs->title );
           prevs->title = g_strdup(pl_entry->title);