From a4e506510b202685d859e366feeeb76e09252ba0 Mon Sep 17 00:00:00 2001 From: Matt Stancliff Date: Sun, 21 Apr 2019 11:14:18 -0400 Subject: [PATCH] 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'. --- src/main.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index c803dfa17c..fd1061107e 100644 --- a/src/main.cpp +++ b/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);