summaryrefslogtreecommitdiff
path: root/src/drivers
diff options
context:
space:
mode:
authorAlbrecht Schlosser <albrechts.fltk@online.de>2024-03-16 15:26:07 +0100
committerAlbrecht Schlosser <albrechts.fltk@online.de>2024-03-16 15:26:07 +0100
commit29aba21b7885d436dba3db87c33d08378b57d23c (patch)
tree67bdcf49cfcd248cc4a7b1aed2dbbe394e9cfdec /src/drivers
parent3ec91d4c6d81915e3b3e48d6342bafceb19f98db (diff)
Fix memory leak in Fl_X11_Screen_Driver.cxx (#934)
Fl_X11_Screen_Driver::set_spot() did not free the list of missing fonts returned by XCreateFontSet(). This commit also initializes some variables and reformats code, but the only notable change is to call XFreeStringList(missing_list) if missing_list is not NULL.
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/X11/Fl_X11_Screen_Driver.cxx34
1 files changed, 15 insertions, 19 deletions
diff --git a/src/drivers/X11/Fl_X11_Screen_Driver.cxx b/src/drivers/X11/Fl_X11_Screen_Driver.cxx
index 76d7801b0..79875366e 100644
--- a/src/drivers/X11/Fl_X11_Screen_Driver.cxx
+++ b/src/drivers/X11/Fl_X11_Screen_Driver.cxx
@@ -1,7 +1,7 @@
//
// Definition of X11 Screen interface
//
-// Copyright 1998-2022 by Bill Spitzak and others.
+// Copyright 1998-2024 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
@@ -429,7 +429,7 @@ extern void fl_fix_focus(); // in Fl.cxx
void Fl_X11_Screen_Driver::grab(Fl_Window* win)
{
const char *p;
- static bool using_kde =
+ static bool using_kde =
( p = getenv("XDG_CURRENT_DESKTOP") , (p && (strcmp(p, "KDE") == 0)) );
Fl_Window *fullscreen_win = NULL;
for (Fl_Window *W = Fl::first_window(); W; W = Fl::next_window(W)) {
@@ -1080,11 +1080,11 @@ void Fl_X11_Screen_Driver::set_spot(int font, int size, int X, int Y, int W, int
int change = 0;
XVaNestedList preedit_attr;
static XFontSet fs = NULL;
- char **missing_list;
- int missing_count;
- char *def_string;
+ char **missing_list = NULL;
+ int missing_count = 0;
+ char *def_string = NULL;
char *fnt = NULL;
- bool must_free_fnt =true;
+ bool must_free_fnt = true;
static XIC ic = NULL;
@@ -1096,7 +1096,7 @@ void Fl_X11_Screen_Driver::set_spot(int font, int size, int X, int Y, int W, int
focuswin = focuswin->window();
}
}
- //XSetICFocus(xim_ic);
+ // XSetICFocus(xim_ic);
if (X != fl_spot.x || Y != fl_spot.y) {
fl_spot.x = X;
fl_spot.y = Y;
@@ -1112,21 +1112,17 @@ void Fl_X11_Screen_Driver::set_spot(int font, int size, int X, int Y, int W, int
XFreeFontSet(fl_display, fs);
}
#if USE_XFT
-
-#if defined(__GNUC__)
- // FIXME: warning XFT support here
-#endif /*__GNUC__*/
-
- fnt = NULL; // fl_get_font_xfld(font, size);
- if (!fnt) {fnt = (char*)"-misc-fixed-*";must_free_fnt=false;}
- fs = XCreateFontSet(fl_display, fnt, &missing_list,
- &missing_count, &def_string);
+ fnt = NULL; // FIXME: missing XFT support here
#else
fnt = fl_get_font_xfld(font, size);
- if (!fnt) {fnt = (char*)"-misc-fixed-*";must_free_fnt=false;}
- fs = XCreateFontSet(fl_display, fnt, &missing_list,
- &missing_count, &def_string);
#endif
+ if (!fnt) {
+ fnt = (char*)"-misc-fixed-*";
+ must_free_fnt = false;
+ }
+ fs = XCreateFontSet(fl_display, fnt, &missing_list, &missing_count, &def_string);
+ if (missing_list)
+ XFreeStringList(missing_list);
}
if (xim_ic != ic) {
ic = xim_ic;