summaryrefslogtreecommitdiff
path: root/ruby.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-23 15:00:55 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-23 15:00:55 +0000
commitb9163cc1fdb109f214cda44b07f2b960338015f4 (patch)
tree376f91267555531d52d5bf54fe82fb7b61525561 /ruby.c
parenta20d306f8a11c94a1da4940b0e10de0af3bf8698 (diff)
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
Diffstat (limited to 'ruby.c')
-rw-r--r--ruby.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/ruby.c b/ruby.c
index bbe4d92ef9..adc1340f83 100644
--- a/ruby.c
+++ b/ruby.c
@@ -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));