From 1a6cf2f1282e4acc6999eff23e828c2009dbdd04 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sun, 7 Oct 2012 20:55:38 +0900 Subject: Fix potential crash when attempting to free default font Before setting a new font we try to free the existing font. Sadly if no config value is set for the default font, we assign a string literal. Which of course means that subsurface dumps core when trying to free it. Signed-off-by: Dirk Hohndel --- linux.c | 2 +- macos.c | 2 +- windows.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/linux.c b/linux.c index 4e7e61c7c..f60f9179c 100644 --- a/linux.c +++ b/linux.c @@ -88,7 +88,7 @@ void subsurface_ui_setup(GtkSettings *settings, GtkWidget *menubar, GtkWidget *vbox, GtkUIManager *ui_manager) { if (!divelist_font) - divelist_font = DIVELIST_DEFAULT_FONT; + divelist_font = strdup(DIVELIST_DEFAULT_FONT); gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, FALSE, 0); } diff --git a/macos.c b/macos.c index 17ae4a411..3cc4ddf1e 100644 --- a/macos.c +++ b/macos.c @@ -116,7 +116,7 @@ void subsurface_ui_setup(GtkSettings *settings, GtkWidget *menubar, GtkWidget *menu_item, *sep; if (!divelist_font) - divelist_font = DIVELIST_MAC_DEFAULT_FONT; + divelist_font = strdup(DIVELIST_MAC_DEFAULT_FONT); g_object_set(G_OBJECT(settings), "gtk-font-name", UI_FONT, NULL); osx_app = g_object_new(GTK_TYPE_OSX_APPLICATION, NULL); diff --git a/windows.c b/windows.c index d0501f875..eedeccf15 100644 --- a/windows.c +++ b/windows.c @@ -155,7 +155,7 @@ void subsurface_ui_setup(GtkSettings *settings, GtkWidget *menubar, GtkWidget *vbox, GtkUIManager *ui_manager) { if (!divelist_font) - divelist_font = DIVELIST_DEFAULT_FONT; + divelist_font = strdup(DIVELIST_DEFAULT_FONT); gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, FALSE, 0); } -- cgit v1.2.3-70-g09d2