diff options
author | Ulrich Sibiller <uli42@gmx.de> | 2020-01-07 20:53:20 +0100 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2020-05-07 12:55:04 +0200 |
commit | bed0d6ce2e3fac3bb85a8dae91ab6ef72e501e28 (patch) | |
tree | bb3e7045b6c5d49d528dcadbf6e7ad2593d4d16b /nx-X11 | |
parent | 8a5c1d3d89e14959ad9aa74d24e3544b50ef37e5 (diff) | |
download | nx-libs-bed0d6ce2e3fac3bb85a8dae91ab6ef72e501e28.tar.gz nx-libs-bed0d6ce2e3fac3bb85a8dae91ab6ef72e501e28.tar.bz2 nx-libs-bed0d6ce2e3fac3bb85a8dae91ab6ef72e501e28.zip |
Atoms.c: always duplicate strings before storing them in privAtomMap
Otherwise we will never be able to free the list because we do not know
if free() is allowed or not.
Diffstat (limited to 'nx-X11')
-rw-r--r-- | nx-X11/programs/Xserver/hw/nxagent/Atoms.c | 37 |
1 files changed, 11 insertions, 26 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Atoms.c b/nx-X11/programs/Xserver/hw/nxagent/Atoms.c index b2d7cdc6f..761ab1b4f 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Atoms.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Atoms.c @@ -374,7 +374,7 @@ static unsigned int privAtomMapSize = 0; static unsigned int privLastAtom = 0; static void nxagentExpandCache(void); -static void nxagentWriteAtom(Atom, XlibAtom, const char*, Bool); +static void nxagentWriteAtom(Atom, XlibAtom, const char*); static AtomMap* nxagentFindAtomByRemoteValue(XlibAtom); static AtomMap* nxagentFindAtomByLocalValue(Atom); static AtomMap* nxagentFindAtomByName(char*, unsigned); @@ -396,31 +396,16 @@ static void nxagentExpandCache(void) * consequent allocation, then cache the atom-couple. */ -static void nxagentWriteAtom(Atom local, XlibAtom remote, const char *string, Bool duplicate) +static void nxagentWriteAtom(Atom local, XlibAtom remote, const char *string) { - const char *s; + const char *s = strdup(string); - /* - * We could remove this string duplication if we knew for sure that - * the server will not reset, since only at reset the dix layer - * frees all the atom names. - */ - - if (duplicate) - { - s = strdup(string); - - #ifdef WARNING - if (s == NULL) - { - fprintf(stderr, "nxagentWriteAtom: Malloc failed.\n"); - } - #endif - } - else + #ifdef WARNING + if (s == NULL) { - s = string; + fprintf(stderr, "nxagentWriteAtom: Malloc failed.\n"); } + #endif if (privLastAtom == privAtomMapSize) { @@ -515,7 +500,7 @@ static int nxagentInitAtomMap(char **atomNameList, int count, Atom *atomsRet) if (ValidAtom(local)) { - nxagentWriteAtom(local, atom_list[i], name_list[i], False); + nxagentWriteAtom(local, atom_list[i], name_list[i]); } else { @@ -673,7 +658,7 @@ XlibAtom nxagentMakeAtom(char *string, unsigned int length, Bool Makeit) } else { - nxagentWriteAtom(local, remote, string, True); + nxagentWriteAtom(local, remote, string); return remote; } @@ -732,7 +717,7 @@ XlibAtom nxagentLocalToRemoteAtom(Atom local) return None; } - nxagentWriteAtom(local, remote, string, True); + nxagentWriteAtom(local, remote, string); #ifdef TEST fprintf(stderr, "%s: local [%d (%s)] -> remote [%d]\n", __func__, local, string, remote); @@ -809,7 +794,7 @@ Atom nxagentRemoteToLocalAtom(XlibAtom remote) local = None; } - nxagentWriteAtom(local, remote, string, True); + nxagentWriteAtom(local, remote, string); #ifdef TEST fprintf(stderr, "%s: remote [%d (%s)] -> local [%d]\n", __func__, remote, string, local); |