diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-10-28 05:07:31 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-10-28 06:04:44 +0300 |
commit | 6445caa9b55cea365da7ace5de006e950746064b (patch) | |
tree | 386297cc519ac24ea58efd10b59a396f7cb1325c /source/blender/blenlib/intern/BLI_args.c | |
parent | c518cd73cdba971f27943f491cdb3525ddcf3176 (diff) |
BLI_args: disallow zero to be used as a pass value
Introduced recently in 09139e41ed4ea.
While this worked in the cases it was used, '--threads' for example
was failing to parse the number when it's pass was set to 0.
Increase the enum values to start at 1 &
add asserts so this wont happen again.
Diffstat (limited to 'source/blender/blenlib/intern/BLI_args.c')
-rw-r--r-- | source/blender/blenlib/intern/BLI_args.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/BLI_args.c b/source/blender/blenlib/intern/BLI_args.c index 4a46bf73f78..45061c5a150 100644 --- a/source/blender/blenlib/intern/BLI_args.c +++ b/source/blender/blenlib/intern/BLI_args.c @@ -120,6 +120,9 @@ bArgs *BLI_argsInit(int argc, const char **argv) ba->argc = argc; ba->argv = argv; + /* Must be initialized by #BLI_argsPassSet. */ + ba->current_pass = 0; + return ba; } @@ -133,6 +136,7 @@ void BLI_argsFree(struct bArgs *ba) void BLI_argsPassSet(struct bArgs *ba, int current_pass) { + BLI_assert((current_pass != 0) && (current_pass >= -1)); ba->current_pass = current_pass; } @@ -278,6 +282,7 @@ void BLI_argsPrintOtherDoc(struct bArgs *ba) void BLI_argsParse(struct bArgs *ba, int pass, BA_ArgCallback default_cb, void *default_data) { + BLI_assert((pass != 0) && (pass >= -1)); int i = 0; for (i = 1; i < ba->argc; i++) { /* skip argv[0] */ |