aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorMatt Stancliff <matt@genges.com>2019-04-21 11:14:18 -0400
committerAndrew Kelley <andrew@ziglang.org>2019-04-29 17:34:23 -0400
commita4e506510b202685d859e366feeeb76e09252ba0 (patch)
treee0a64414ed217203ffa1fce54240fb37dffce066 /src/main.cpp
parente3452ba21b978f8b675e90e3b580e325ae0e38a6 (diff)
downloadzig-a4e506510b202685d859e366feeeb76e09252ba0.tar.gz
zig-a4e506510b202685d859e366feeeb76e09252ba0.zip
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'.
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp6
1 files changed, 5 insertions, 1 deletions
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);