diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2023-10-08 12:02:58 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2023-10-08 12:07:02 -0700 |
commit | 340dd95c6a566b01bfaf9ce2baa0b49f07e3ac22 (patch) | |
tree | fa1420899e51f1045338a313c90cdd7ec7eed4ce /src | |
parent | a8c782571d3b2419404f3a623f4b5396cd5e7aa4 (diff) |
XkbChangeAtomDisplay: stop leaking atom name
Found by gcc 12 analyzer:
xkbatom.c: In function ‘XkbChangeAtomDisplay’:
xkbatom.c:218:16: warning: leak of ‘tmp’ [CWE-401] [-Wanalyzer-malloc-leak]
xkbatom.c:220:12: warning: leak of ‘tmp’ [CWE-401] [-Wanalyzer-malloc-leak]
220 | return XInternAtom(dpy, name, onlyIfExists);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fixes: 5e5bd09 ("Fix offline operation.")
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/xkbatom.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/xkbatom.c b/src/xkbatom.c index b6feac6..3a7e08b 100644 --- a/src/xkbatom.c +++ b/src/xkbatom.c @@ -225,12 +225,13 @@ XkbInternAtom(Display *dpy, const char *name, Bool onlyIfExists) Atom XkbChangeAtomDisplay(Display *oldDpy, Display *newDpy, Atom atm) { - char *tmp; - if (atm != None) { - tmp = XkbAtomGetString(oldDpy, atm); - if (tmp != NULL) - return XkbInternAtom(newDpy, tmp, False); + char *tmp = XkbAtomGetString(oldDpy, atm); + if (tmp != NULL) { + Atom a = XkbInternAtom(newDpy, tmp, False); + _XkbFree(tmp); + return a; + } } return None; } |