[PATCH:setxkbmap] Fix crash when when -device is specified without argument

Alan Coopersmith alan.coopersmith at oracle.com
Tue Jan 18 22:35:59 PST 2011


From: Stuart Kreitman <stuart.kreitman at oracle.com>

http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=6971649

Signed-off-by: Stuart Kreitman <stuart.kreitman at oracle.com>
Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 setxkbmap.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/setxkbmap.c b/setxkbmap.c
index 338b06c..e812a9c 100644
--- a/setxkbmap.c
+++ b/setxkbmap.c
@@ -397,7 +397,14 @@ parseArgs(int argc, char **argv)
         else if (streq(argv[i], "-config"))
             ok = setOptString(&i, argc, argv, CONFIG_NDX, FROM_CMD_LINE);
         else if (streq(argv[i], "-device"))
-            deviceSpec = atoi(argv[++i]); /* only allow device IDs, not names */
+        {
+            if ( ++i < argc ) {
+                deviceSpec = atoi(argv[i]); /* only allow device IDs, not names */
+            } else {
+                usage(argc, argv);
+                exit(-1);
+            }
+        }
         else if (streq(argv[i], "-display"))
             ok = setOptString(&i, argc, argv, DISPLAY_NDX, FROM_CMD_LINE);
         else if (streq(argv[i], "-geometry"))
-- 
1.7.3.2



More information about the xorg-devel mailing list