xkbcomp broken - (EE) XKB: Couldn't compile keymap

Peter Hutterer peter.hutterer at who-t.net
Wed Sep 10 01:22:17 PDT 2008


strdup doesn't like NULL strings, so xkbcomp may segfault when parsing xkb
files. There's a fair view callers in xkbcomp that use uStringDup and assume
it handles NULL strings, so just fixing the macro is the easy way out (see the
patch below).

Alan - any objections?

Alternatively, we could change all callers to pre-check.


>From 514e223705baeba3aeb9023ee1a69a2dc465b2e5 Mon Sep 17 00:00:00 2001
From: Peter Hutterer <peter.hutterer at redhat.com>
Date: Wed, 10 Sep 2008 17:48:29 +0930
Subject: [PATCH] Check for NULL strings before calling strdup.

Signed-off-by: Peter Hutterer <peter.hutterer at redhat.com>
---
 utils.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/utils.h b/utils.h
index 0f38052..e608c9b 100644
--- a/utils.h
+++ b/utils.h
@@ -247,7 +247,7 @@ uInformation(const char * /* s */ , ...
     );
 #endif
 #ifdef HAVE_STRDUP
-#define	uStringDup(s1)		(strdup(s1))
+#define	uStringDup(s1)		((s1) ? strdup(s1) : NULL)
 #else
      extern char *uStringDup(const char *       /* s1 */
     );
-- 
1.6.0.1





More information about the xorg mailing list