Skip to content

Commit a834dff

Browse files
author
Rik
committed
Avoid crash when Octave invoked with '-d' argument.
* options.h (short_opts): Remove 'd' from list of short options that getopts() will accept. * octave.cc: #include <cstdlib> for access to exit() function. * octave.cc (cmdline_options): Replace call to Octave error() function (which requires an interpreter to available) with call to std::cerr to output error message and std::exit to stop the program.
1 parent 72fc7d9 commit a834dff

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

libinterp/octave.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
# include "config.h"
3030
#endif
3131

32+
#include <cstdlib>
33+
3234
#include <iostream>
3335
#include <string>
3436

@@ -230,9 +232,9 @@ cmdline_options::cmdline_options (int argc, char **argv)
230232
// getopt_long should print a message about unrecognized options and
231233
// return '?', which is handled above. If we end up here, it is
232234
// because there was an option but we forgot to handle it.
233-
// That should be fatal.
234-
235-
error ("unexpected option (= %d) - please reportt this bug", optc);
235+
// This is fatal.
236+
std::cerr << "unexpected option (= " << optc << ") - please report this bug\n";
237+
std::exit (EXIT_FAILURE);
236238
break;
237239
}
238240
}

libinterp/options.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
// This is here so that it's more likely that the usage message and
3434
// the real set of options will agree. Note: the '+' must come first
3535
// to prevent getopt from permuting arguments!
36-
static const char *short_opts = "+GHWVde:fghip:qvx";
36+
static const char *short_opts = "+GHWVe:fghip:qvx";
3737

3838
// Long options. See the comments in getopt.h for the meanings of the
3939
// fields in this structure.

0 commit comments

Comments
 (0)