Add more error handling code to logging of enum vals. (addresses #829)

If lookup of enum name by value fails, an error is now sent through
the reporter framework and the value logged will be an empty string
(as opposed to trying to construct a string with null pointer which
throws a logic_error and aborts Bro).
This commit is contained in:
Jon Siwek 2012-06-08 10:11:54 -05:00
parent 9a86a5e21f
commit e9c18b51a3

View file

@ -819,7 +819,13 @@ threading::Value* Manager::ValToLogVal(Val* val, BroType* ty)
const char* s =
val->Type()->AsEnumType()->Lookup(val->InternalInt());
lval->val.string_val = new string(s);
if ( s )
lval->val.string_val = new string(s);
else
{
val->Type()->Error("enum type does not contain value", val);
lval->val.string_val = new string();
}
break;
}