From 601a0f0d3efd46b0ef6c34a98cd738bceaae504c Mon Sep 17 00:00:00 2001 From: Fabien Costantini Date: Sun, 4 Jan 2009 16:21:42 +0000 Subject: + Fixed font set to const string was potentially free in Fl_x.cxx:fl_set_spot() + Fixed fl_ask.h erroneous include replaced by fl_ask.H include in colbrowser.cxx git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6622 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_x.cxx | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/Fl_x.cxx b/src/Fl_x.cxx index 31599a620..e91a58985 100644 --- a/src/Fl_x.cxx +++ b/src/Fl_x.cxx @@ -330,6 +330,7 @@ void fl_new_ic() XVaNestedList status_attr = NULL; static XFontSet fs = NULL; char *fnt; + bool must_free_fnt = true; char **missing_list; int missing_count; char *def_string; @@ -342,14 +343,14 @@ void fl_new_ic() #warning XFT support here if (!fs) { fnt = NULL;//fl_get_font_xfld(0, 14); - if (!fnt) fnt = "-misc-fixed-*"; + if (!fnt) {fnt = "-misc-fixed-*";must_free_fnt=false;} fs = XCreateFontSet(fl_display, fnt, &missing_list, &missing_count, &def_string); } #else if (!fs) { fnt = fl_get_font_xfld(0, 14); - if (!fnt) fnt = "-misc-fixed-*"; + if (!fnt) {fnt = "-misc-fixed-*";must_free_fnt=false;} fs = XCreateFontSet(fl_display, fnt, &missing_list, &missing_count, &def_string); } @@ -431,7 +432,9 @@ void fl_set_spot(int font, int size, int X, int Y, int W, int H, Fl_Window *win) char **missing_list; int missing_count; char *def_string; - char *fnt; + char *fnt=NULL; + bool must_free_fnt=true; + static XIC ic = NULL; if (!fl_xim_ic || !fl_is_over_the_spot) return; @@ -452,17 +455,15 @@ void fl_set_spot(int font, int size, int X, int Y, int W, int H, Fl_Window *win) } #if USE_XFT #warning XFT support here - fnt = NULL;//fl_get_font_xfld(font, size); - if (!fnt) fnt = "-misc-fixed-*"; + fnt = NULL; // fl_get_font_xfld(font, size); + if (!fnt) {fnt = "-misc-fixed-*";must_free_fnt=false;} fs = XCreateFontSet(fl_display, fnt, &missing_list, &missing_count, &def_string); - free(fnt); #else fnt = fl_get_font_xfld(font, size); - if (!fnt) fnt = "-misc-fixed-*"; + if (!fnt) {fnt = "-misc-fixed-*";must_free_fnt=false;} fs = XCreateFontSet(fl_display, fnt, &missing_list, &missing_count, &def_string); - free(fnt); #endif } if (fl_xim_ic != ic) { @@ -470,6 +471,7 @@ void fl_set_spot(int font, int size, int X, int Y, int W, int H, Fl_Window *win) change = 1; } + if (fnt && must_free_fnt) free(fnt); if (!change) return; -- cgit v1.2.3