[evolution] e_web_view_update_fonts(): Fix memory corruption.



commit 3ade9a67e9af31f89b707040ce89b6e20bfbdfd1
Author: Matthew Barnes <mbarnes redhat com>
Date:   Sat Jul 7 08:37:19 2012 -0400

    e_web_view_update_fonts(): Fix memory corruption.
    
    Boxed GdkColors are allocated with the slice allocator, not malloc().
    
    This has been causing me frequent and random Evolution crashes.

 widgets/misc/e-web-view.c |   18 ++++++++----------
 1 files changed, 8 insertions(+), 10 deletions(-)
---
diff --git a/widgets/misc/e-web-view.c b/widgets/misc/e-web-view.c
index 8d5d614..5a65ad7 100644
--- a/widgets/misc/e-web-view.c
+++ b/widgets/misc/e-web-view.c
@@ -2908,7 +2908,8 @@ e_web_view_update_fonts (EWebView *web_view)
 	const gchar *styles[] = { "normal", "oblique", "italic" };
 	const gchar *smoothing = NULL;
 	GtkStyleContext *context;
-	GdkColor *link, *visited;
+	GdkColor *link = NULL;
+	GdkColor *visited = NULL;
 
 	ms = NULL;
 	vw = NULL;
@@ -2999,13 +3000,13 @@ e_web_view_update_fonts (EWebView *web_view)
 		"visited-link-color", &visited,
 		NULL);
 
-	if (!link) {
-		link = g_new0 (GdkColor, 1);
+	if (link == NULL) {
+		link = g_slice_new0 (GdkColor);
 		link->blue = G_MAXINT16;
 	}
 
-	if (!visited) {
-		visited = g_new0 (GdkColor, 1);
+	if (visited == NULL) {
+		visited = g_slice_new0 (GdkColor);
 		visited->red = G_MAXINT16;
 	}
 
@@ -3019,11 +3020,8 @@ e_web_view_update_fonts (EWebView *web_view)
 		e_color_to_value (link),
 		e_color_to_value (visited));
 
-	if (link)
-		gdk_color_free (link);
-
-	if (visited)
-		gdk_color_free (visited);
+	gdk_color_free (link);
+	gdk_color_free (visited);
 
 	base64 = g_base64_encode ((guchar *) stylesheet->str, stylesheet->len);
 	g_string_free (stylesheet, TRUE);



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