Skip to content
Permalink
Browse files
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'.
  • Loading branch information
mattsta authored and andrewrk committed Apr 29, 2019
1 parent e3452ba commit a4e506510b202685d859e366feeeb76e09252ba0
Showing with 5 additions and 1 deletion.
  1. +5 −1 src/main.cpp
@@ -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);

0 comments on commit a4e5065

Please sign in to comment.