Fix crash due to command line argument parsing

zig --help -> ok
zig --help --c-source -> ok
zig --c-source --help -> crash [fixed]

'i' was being incremented without regard for the 'argc' limit, so
we were running off the end of 'argv'.
This commit is contained in:
Matt Stancliff
2019-04-21 11:14:18 -04:00
committed by Andrew Kelley
parent e3452ba21b
commit a4e506510b

View File

@@ -755,7 +755,11 @@ int main(int argc, char **argv) {
if (argv[i][0] == '-') {
c_file->args.append(argv[i]);
i += 1;
continue;
if (i < argc) {
continue;
}
break;
} else {
c_file->source_path = argv[i];
c_source_files.append(c_file);