diff options
author | Stuart Kreitman <stuart.kreitman@oracle.com> | 2011-01-18 22:33:34 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2011-01-19 16:42:50 -0800 |
commit | 7bacea73e67e6882cef51840bb98d1bafb8f2291 (patch) | |
tree | 0a1df7969600b19f00d1edb872b737f9fb0385b8 | |
parent | 059eb4e0745b8a00f3d456c539eb0df714ed1b90 (diff) |
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 <stuart.kreitman@oracle.com>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Dirk Wallenstein <halsmit@t-online.de>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
-rw-r--r-- | 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")) |