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 <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2012-10-07 20:55:38 +09:00
parent b4c11a7ed3
commit 1a6cf2f128
3 changed files with 3 additions and 3 deletions

View file

@ -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);
}

View file

@ -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);

View file

@ -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);
}