Patchwork ui: do not call XGetAtomName if keycodes is not an atom

login
register
mail settings
Submitter Alex Suykov
Date July 6, 2012, 11:01 p.m.
Message ID <20120706230117.GA25054@vostro.bugs>
Download mbox | patch
Permalink /patch/169555/
State New
Headers show

Comments

Alex Suykov - July 6, 2012, 11:01 p.m.
XkbGetKeyboard may return zero instead of a valid atom
in names->keycodes in some cases. XGetAtomName(dpy, 0)
results in BadAtom error and crashes qemu.

Signed-off-by: Alex Suykov <alex.suykov@gmail.com>
---
 ui/sdl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch

diff --git a/ui/sdl.c b/ui/sdl.c
index f6f711c..e74b892 100644
--- a/ui/sdl.c
+++ b/ui/sdl.c
@@ -269,7 +269,7 @@  static int check_for_evdev(void)
     desc = XkbGetKeyboard(info.info.x11.display,
                           XkbGBN_AllComponentsMask,
                           XkbUseCoreKbd);
-    if (desc && desc->names) {
+    if (desc && desc->names && desc->names->keycodes) {
         keycodes = XGetAtomName(info.info.x11.display, desc->names->keycodes);
         if (keycodes == NULL) {
             fprintf(stderr, "could not lookup keycode name\n");