aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoranzz1 <anzz1@live.com>2023-03-25 14:42:09 +0200
committerGitHub <noreply@github.com>2023-03-25 14:42:09 +0200
commite899bf54b291e8c84173a0e534a2c262f3f63229 (patch)
treebb63e9aec37ef4c713762de1efda6259bbdab81a
parentfbd4d38c647f82b2598291ea9b8d0c09ac1ffb8c (diff)
bounds checking for input prefix (#492)
-rw-r--r--utils.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/utils.cpp b/utils.cpp
index ef3b67a..319924c 100644
--- a/utils.cpp
+++ b/utils.cpp
@@ -156,7 +156,11 @@ bool gpt_params_parse(int argc, char ** argv, gpt_params & params) {
} else if (arg == "--random-prompt") {
params.random_prompt = true;
} else if (arg == "--in-prefix") {
- params.input_prefix = argv[++i];
+ if (++i >= argc) {
+ invalid_param = true;
+ break;
+ }
+ params.input_prefix = argv[i];
} else {
fprintf(stderr, "error: unknown argument: %s\n", arg.c_str());
gpt_print_usage(argc, argv, params);