diff options
author | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2021-01-16 00:24:10 +0100 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2021-01-16 00:24:10 +0100 |
commit | 8c3bb27150bf058c007af1318cb477e9763b9d9d (patch) | |
tree | 794b78e31d0ffdff0a41ecec3869afee542410ba /nx-X11/programs/Xserver/hw/nxagent/Atoms.c | |
parent | b66699555d2e2503926f01a9c192481e01812399 (diff) | |
parent | 1b80750f69a848c1c00c15c537707acca4e68684 (diff) | |
download | nx-libs-8c3bb27150bf058c007af1318cb477e9763b9d9d.tar.gz nx-libs-8c3bb27150bf058c007af1318cb477e9763b9d9d.tar.bz2 nx-libs-8c3bb27150bf058c007af1318cb477e9763b9d9d.zip |
Merge branch 'uli42-pr/pvs_findings' into 3.6.x
Attributes GH PR #981: https://github.com/ArcticaProject/nx-libs/pull/981
Diffstat (limited to 'nx-X11/programs/Xserver/hw/nxagent/Atoms.c')
-rw-r--r-- | nx-X11/programs/Xserver/hw/nxagent/Atoms.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Atoms.c b/nx-X11/programs/Xserver/hw/nxagent/Atoms.c index c15674f5e..ea7ad7599 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Atoms.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Atoms.c @@ -385,12 +385,16 @@ static void nxagentExpandCache(void) { privAtomMapSize += NXAGENT_ATOM_MAP_SIZE_INCREMENT; - privAtomMap = realloc(privAtomMap, privAtomMapSize * sizeof(AtomMap)); + AtomMap * newmap = realloc(privAtomMap, privAtomMapSize * sizeof(AtomMap)); - if (privAtomMap == NULL) + if (newmap == NULL) { FatalError("nxagentExpandCache: realloc failed\n"); } + else + { + privAtomMap = newmap; + } } /* @@ -405,19 +409,23 @@ static void nxagentWriteAtom(Atom local, XlibAtom remote, const char *string) #ifdef WARNING if (s == NULL) { - fprintf(stderr, "nxagentWriteAtom: Malloc failed.\n"); + /* we only warn here, because s being NULL ist not problem, it + will only result in NULL being stored in the privAtomMap, which + is perfectly legal. */ + fprintf(stderr, "%s: Malloc failed.\n", __func__); } #endif if (privLastAtom == privAtomMapSize) { + /* will issue a fatal error, therefore no further check here */ nxagentExpandCache(); } privAtomMap[privLastAtom].local = local; privAtomMap[privLastAtom].remote = remote; privAtomMap[privLastAtom].string = s; - privAtomMap[privLastAtom].length = strlen(s); + privAtomMap[privLastAtom].length = s ? strlen(s) : 0; privLastAtom++; } |