From 3ade9a67e9af31f89b707040ce89b6e20bfbdfd1 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 7 Jul 2012 08:37:19 -0400 Subject: 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 file changed, 8 insertions(+), 10 deletions(-) diff --git a/widgets/misc/e-web-view.c b/widgets/misc/e-web-view.c index 8d5d614bce..5a65ad7155 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); -- cgit v1.2.3