From 7bacea73e67e6882cef51840bb98d1bafb8f2291 Mon Sep 17 00:00:00 2001 From: Stuart Kreitman Date: Tue, 18 Jan 2011 22:33:34 -0800 Subject: Fix crash when when -device is specified without argument http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=6971649 Signed-off-by: Stuart Kreitman Signed-off-by: Alan Coopersmith Reviewed-by: Dirk Wallenstein Reviewed-by: Daniel Stone --- setxkbmap.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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")) -- cgit v1.2.3