1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

ruby.c: argv check

* ruby.c (proc_options, process_options, ruby_process_options): take
  care of the case argc is 0, and check if argv has NULL.
  [ruby-core:49889] [Bug #7423]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37823 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2012-11-23 15:00:55 +00:00
parent a20d306f8a
commit b9163cc1fd
2 changed files with 10 additions and 3 deletions

View file

@ -1,3 +1,9 @@
Sat Nov 24 00:00:53 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ruby.c (proc_options, process_options, ruby_process_options): take
care of the case argc is 0, and check if argv has NULL.
[ruby-core:49889] [Bug #7423]
Sat Nov 24 00:00:10 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* configure.in (--disable-dln): option to disable dynamic linking

7
ruby.c
View file

@ -775,7 +775,7 @@ proc_options(long argc, char **argv, struct cmdline_options *opt, int envopt)
for (argc--, argv++; argc > 0; argc--, argv++) {
const char *const arg = argv[0];
if (arg[0] != '-' || !arg[1])
if (!arg || arg[0] != '-' || !arg[1])
break;
s = arg + 1;
@ -1358,7 +1358,7 @@ process_options(int argc, char **argv, struct cmdline_options *opt)
}
else {
opt->script = argv[0];
if (opt->script[0] == '\0') {
if (!opt->script || opt->script[0] == '\0') {
opt->script = "-";
}
else if (opt->do_search) {
@ -1896,8 +1896,9 @@ ruby_process_options(int argc, char **argv)
{
struct cmdline_options opt;
VALUE iseq;
const char *script_name = (argc > 0 && argv[0]) ? argv[0] : "ruby";
ruby_script(argv[0]); /* for the time being */
ruby_script(script_name); /* for the time being */
rb_argv0 = rb_str_new4(rb_progname);
rb_gc_register_mark_object(rb_argv0);
iseq = process_options(argc, argv, cmdline_options_init(&opt));