diff options
author | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2020-11-03 14:00:40 +0100 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2020-11-03 14:00:40 +0100 |
commit | ced973e36f67f78cef720d0fc54e47bb8e5b22a6 (patch) | |
tree | 5cc0c3d5235f4ff1bc30ab36904bdc0468832ef7 /nx-X11/programs/Xserver/hw/nxagent | |
parent | 14df32cdb8fde8a3807f677af5bd81d718234379 (diff) | |
parent | db45683a6317a8712bbdbff0615d1b8e39b5d57c (diff) | |
download | nx-libs-ced973e36f67f78cef720d0fc54e47bb8e5b22a6.tar.gz nx-libs-ced973e36f67f78cef720d0fc54e47bb8e5b22a6.tar.bz2 nx-libs-ced973e36f67f78cef720d0fc54e47bb8e5b22a6.zip |
Merge branch 'uli42-pr/font_memleak' into 3.6.x
Attributes GH PR #949: https://github.com/ArcticaProject/nx-libs/pull/949
Diffstat (limited to 'nx-X11/programs/Xserver/hw/nxagent')
-rw-r--r-- | nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c | 62 |
1 files changed, 56 insertions, 6 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c b/nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c index 6bb4ea306..516b7eb02 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c @@ -924,6 +924,9 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c) ContBadFontName: ; c->current.list_started = FALSE; c->current.current_fpe++; +#ifdef NXAGENT_SERVER + c->current.private = 0; /* BadFontName -> private has been freed */ +#endif err = Successful; if (c->haveSaved) { @@ -1070,6 +1073,7 @@ nxdoListFontsAndAliases(ClientPtr client, nxFsPtr fss) int i; int aliascount = 0; char tmp[256]; + tmp[0] = 0; if (client->clientGone) { @@ -1195,6 +1199,13 @@ nxdoListFontsAndAliases(ClientPtr client, nxFsPtr fss) if (err == Successful) { +#ifndef BREAK_XFONT_LOOP + if (tmp[0] != 0) + { + continue; + } +#endif + if (c->haveSaved) { if (c->savedName) @@ -1202,8 +1213,14 @@ nxdoListFontsAndAliases(ClientPtr client, nxFsPtr fss) memcpy(tmp, c->savedName, c->savedNameLen > 255 ? 255 : c->savedNameLen); tmp[c->savedNameLen >255 ? 255 : c->savedNameLen] = 0; if (nxagentFontLookUp(tmp)) - break; - else tmp[0] = 0; + { +#ifdef BREAK_XFONT_LOOP + break; +#else + continue; +#endif + } + else tmp[0] = 0; } } else @@ -1211,7 +1228,13 @@ nxdoListFontsAndAliases(ClientPtr client, nxFsPtr fss) memcpy(tmp, name, namelen > 255 ? 255 : namelen); tmp[namelen > 255 ? 255 : namelen] = 0; if (nxagentFontLookUp(tmp)) - break; + { +#ifdef BREAK_XFONT_LOOP + break; +#else + continue; +#endif + } else tmp[0] = 0; } } @@ -1282,6 +1305,10 @@ nxdoListFontsAndAliases(ClientPtr client, nxFsPtr fss) ContBadFontName: ; c->current.list_started = FALSE; c->current.current_fpe++; +#ifdef NXAGENT_SERVER + /* clearing a freed pointer helps for debugging */ + c->current.private = 0; /* BadFontName means private has been freed */ +#endif err = Successful; if (c->haveSaved) { @@ -1298,11 +1325,34 @@ nxdoListFontsAndAliases(ClientPtr client, nxFsPtr fss) } } - /* - * send the reply - */ bail: finish: +#ifdef BREAK_XFONT_LOOP + /* if we allow above loop to be exited via break + we need to free the private xfont data somehow. */ + if (c->current.list_started) + { + /* WARNING: this codes makes assumptions about an internal + private structure of libXfont and can therefore break with + ANY libXfont update! */ + typedef struct _LFWIData { + FontNamesPtr names; + int current; + } LFWIDataRec, *LFWIDataPtr; + + LFWIDataPtr data = c->current.private; + if (data) + { +#ifdef HAS_XFONT2 + xfont2_free_font_names(data->names); +#else + FreeFontName(data->names); +#endif + free(data); + } + } +#endif + if (strlen(tmp)) { #ifdef NXAGENT_FONTMATCH_DEBUG |