From 0cf8876f8a374f8fb23f039ca39107f8ac7bfd78 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 21 Sep 2022 06:40:03 +0530 Subject: [PATCH] Validate count struct fields --- tools/cli/option-from-string.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/cli/option-from-string.go b/tools/cli/option-from-string.go index 5a1f1c6c0..0172a69d2 100644 --- a/tools/cli/option-from-string.go +++ b/tools/cli/option-from-string.go @@ -74,6 +74,9 @@ func OptionsFromStruct(pointer_to_options_struct interface{}) ([]*Option, error) if err != nil { return nil, err } + if opt.OptionType == CountOption && f.Kind() != reflect.Int { + return nil, fmt.Errorf("The field %s is of count type but in the options struct it does not have type int", field_name) + } ans = append(ans, opt) }