avoid passing NULL to fopen

This commit is contained in:
nkshigeru
2012-05-17 15:54:34 +09:00
parent d65542cca8
commit bd485b5940
+2 -1
View File
@@ -105,7 +105,8 @@ parse_args(mrb_state *mrb, int argc, char **argv, struct _args *args)
}
if (args->rfp == NULL && args->cmdline == NULL && (args->rfp = fopen(*argv, args->mrbfile ? "rb" : "r")) == NULL) {
if (args->rfp == NULL && args->cmdline == NULL &&
(*argv == NULL || (args->rfp = fopen(*argv, args->mrbfile ? "rb" : "r")) == NULL)) {
printf("%s: Cannot open program file. (%s)\n", *origargv, *argv);
return 0;
}