summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2023-10-08 11:24:05 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2023-10-08 11:24:05 -0700
commitd44b8926620bf6d033062557441d1aa935a0ac02 (patch)
tree1a9722b3ddae6974ecd809d065f8c77b582de740
parent20b6672a6d7d5531ff1db1e5af762c052bf883bf (diff)
_XkbMakeAtom: remove check for impossible case
nd->string is always the result of a new allocation, so can never be equal to string. This resolves a warning from the gcc 12 analyzer, which reported a memory leak if the impossible condition was ever true: In file included from xkbatom.c:85: xkbatom.c: In function ‘_XkbMakeAtom’: XKBfileInt.h:51:33: warning: leak of ‘<unknown>’ [CWE-401] [-Wanalyzer-malloc-leak] [...] | 158 | if (!table) { | | ^ | | | | | (15) following ‘true’ branch (when ‘table’ is NULL)... | 159 | if (nd->string != string) | | ~~ ~ | | | | | | | (17) following ‘false’ branch... | | (16) ...to here | 161 | _XkbFree(nd); | | ^~~~~~~~ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--src/xkbatom.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/xkbatom.c b/src/xkbatom.c
index 564cc83..3e8b9c0 100644
--- a/src/xkbatom.c
+++ b/src/xkbatom.c
@@ -156,8 +156,7 @@ _XkbMakeAtom(const char *string, size_t len, Bool makeit)
tableLength * (2 *
sizeof(NodePtr)));
if (!table) {
- if (nd->string != string)
- _XkbFree(nd->string);
+ _XkbFree(nd->string);
_XkbFree(nd);
return BAD_RESOURCE;
}