Commit 82d41b1
committed
toke: fix getopt with invalid combined short options
When combining invalid short options, toke just segfaults:
$ toke -ab
Welcome to toke - FCode tokenizer v1.0.3
(C) Copyright 2001-2010 Stefan Reinauer.
(C) Copyright 2006 coresystems GmbH
(C) Copyright 2005 IBM Corporation. All Rights Reserved.
This program is free software; you may redistribute it under the terms of
the GNU General Public License v2. This program has absolutely no warranty.
./toke: invalid option -- 'a'
./toke: invalid option -- 'b'
Segmentation fault (core dumped)
This happens because argindx represent the number of the option, not the
number of the argument on the command line. Fix that by looking at the
optopt variable instead.
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>1 parent 7d392bb commit 82d41b1
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
298 | 298 | | |
299 | 299 | | |
300 | 300 | | |
301 | | - | |
| 301 | + | |
302 | 302 | | |
303 | 303 | | |
304 | 304 | | |
| |||
0 commit comments