[evolution/rendering-cleanup] GnomeCanvasShape: Make color string parsing more robust



commit f33dd2399b8bbd3b08866dba5168de0724b690d0
Author: Matthew Barnes <mbarnes redhat com>
Date:   Thu Oct 28 18:34:02 2010 -0400

    GnomeCanvasShape: Make color string parsing more robust

 libgnomecanvas/gnome-canvas-shape.c |   21 +++++++++++++++++----
 1 files changed, 17 insertions(+), 4 deletions(-)
---
diff --git a/libgnomecanvas/gnome-canvas-shape.c b/libgnomecanvas/gnome-canvas-shape.c
index d506fc8..0ef588c 100644
--- a/libgnomecanvas/gnome-canvas-shape.c
+++ b/libgnomecanvas/gnome-canvas-shape.c
@@ -245,6 +245,7 @@ gnome_canvas_shape_set_property (GObject      *object,
 	GnomeCanvasShapePriv    *priv;
 	GdkColor                 color;
 	GdkColor                *colorptr;
+	const gchar             *color_string;
 
 	item = GNOME_CANVAS_ITEM (object);
 	shape = GNOME_CANVAS_SHAPE (object);
@@ -252,8 +253,14 @@ gnome_canvas_shape_set_property (GObject      *object,
 
 	switch (param_id) {
 	case PROP_FILL_COLOR:
-		if (g_value_get_string (value) &&
-                    gdk_color_parse (g_value_get_string (value), &color)) {
+		color_string = g_value_get_string (value);
+		if (color_string != NULL) {
+			if (gdk_color_parse (color_string, &color)) {
+				g_warning (
+					"Failed to parse color '%s'",
+					color_string);
+				break;
+			}
 			priv->fill_set = TRUE;
 			priv->fill_rgba = get_rgba_from_color (&color);
 		} else if (priv->fill_set)
@@ -285,8 +292,14 @@ gnome_canvas_shape_set_property (GObject      *object,
 		break;
 
 	case PROP_OUTLINE_COLOR:
-		if (g_value_get_string (value) &&
-                    gdk_color_parse (g_value_get_string (value), &color)) {
+		color_string = g_value_get_string (value);
+		if (color_string != NULL) {
+			if (!gdk_color_parse (color_string, &color)) {
+				g_warning (
+					"Failed to parse color '%s'",
+					color_string);
+				break;
+			}
 			priv->outline_set = TRUE;
 			priv->outline_rgba = get_rgba_from_color (&color);
 		} else if (priv->outline_set)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]