diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-23 15:00:55 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-23 15:00:55 +0000 |
commit | b9163cc1fdb109f214cda44b07f2b960338015f4 (patch) | |
tree | 376f91267555531d52d5bf54fe82fb7b61525561 | |
parent | a20d306f8a11c94a1da4940b0e10de0af3bf8698 (diff) | |
download | ruby-b9163cc1fdb109f214cda44b07f2b960338015f4.tar.gz |
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
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | ruby.c | 7 |
2 files changed, 10 insertions, 3 deletions
@@ -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 @@ -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)); |