GH-1555: Fix reading empty set[enum] values from config files

This commit is contained in:
Jon Siwek 2021-05-14 16:32:19 -07:00
parent 09ff24199b
commit e35888a994
3 changed files with 12 additions and 2 deletions

View file

@ -519,7 +519,8 @@ Val* Value::ValueToVal(const std::string& source, const Value* val, bool& have_e
case TYPE_TABLE: case TYPE_TABLE:
{ {
TypeListPtr set_index; TypeListPtr set_index;
if ( val->val.set_val.size == 0 && val->subtype == TYPE_VOID ) if ( val->val.set_val.size == 0 &&
( val->subtype == TYPE_VOID || val->subtype == TYPE_ENUM ) )
// don't know type - unspecified table. // don't know type - unspecified table.
set_index = make_intrusive<TypeList>(); set_index = make_intrusive<TypeList>();
else else

View file

@ -3,3 +3,6 @@
Red, Red,
Green Green
} }
{
}

View file

@ -5,6 +5,7 @@
@TEST-START-FILE configfile @TEST-START-FILE configfile
mycolors Red,asdf,Blue mycolors Red,asdf,Blue
nocolors
@TEST-END-FILE @TEST-END-FILE
@load base/frameworks/config @load base/frameworks/config
@ -12,9 +13,14 @@ mycolors Red,asdf,Blue
type Color: enum { Red, Green, Blue, }; type Color: enum { Red, Green, Blue, };
option mycolors = set(Red, Green); option mycolors = set(Red, Green);
option nocolors = set(Red, Green);
event zeek_init() event zeek_init()
{ Config::read_config("../configfile"); } { Config::read_config("../configfile"); }
event Input::end_of_data(name: string, source:string) event Input::end_of_data(name: string, source:string)
{ print mycolors; terminate(); } {
print mycolors;
print nocolors;
terminate();
}