[Xfce4-commits] <xfce4-xkb-plugin:master> Check for UTF8 validity before using the normalized group name.

Jérôme Guelfucci noreply at xfce.org
Thu Apr 28 21:26:04 CEST 2011


Updating branch refs/heads/master
         to 3d4cfd88fb202dad4748b5a36b67022538872494 (commit)
       from a7ed90a4019db00b150b3c0bb4779dae3570cca6 (commit)

commit 3d4cfd88fb202dad4748b5a36b67022538872494
Author: Jérôme Guelfucci <jeromeg at xfce.org>
Date:   Thu Apr 28 19:25:40 2011 +0200

    Check for UTF8 validity before using the normalized group name.

 panel-plugin/xkb-cairo.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/panel-plugin/xkb-cairo.c b/panel-plugin/xkb-cairo.c
index d080963..d74c296 100644
--- a/panel-plugin/xkb-cairo.c
+++ b/panel-plugin/xkb-cairo.c
@@ -149,7 +149,7 @@ xkb_cairo_draw_label (cairo_t *cr,
 {
     g_assert (cr != NULL);
 
-    gchar **normalized_group_name;
+    gchar *normalized_group_name;
     gchar font_str[80];
     gint pango_width, pango_height;
     gint layoutx, layouty;
@@ -157,11 +157,17 @@ xkb_cairo_draw_label (cairo_t *cr,
     gint i;
     gint radius;
 
-    normalized_group_name = xkb_util_normalize_group_name (group_name);
-
     PangoLayout *layout;
     PangoFontDescription *desc;
+
     layout = pango_cairo_create_layout (cr);
+    normalized_group_name = xkb_util_normalize_group_name (group_name);
+
+    if (!g_utf8_validate (normalized_group_name, -1, NULL))
+    {
+        g_object_unref (layout);
+        g_free (normalized_group_name);
+    }
 
     pango_layout_set_text (layout, normalized_group_name, -1);
     g_sprintf (font_str, XKB_PREFERRED_FONT, font_sizes[panel_size - 16]);



More information about the Xfce4-commits mailing list