mirror of
https://github.com/zeek/zeek.git
synced 2025-10-07 00:58:19 +00:00
Fix seg fault on trying to type-cast invalid/nil Broker::Data
This situation now throws a runtime expression exception instead of crashing on null pointer access.
This commit is contained in:
parent
0e6913fba0
commit
f336c8c710
6 changed files with 28 additions and 4 deletions
|
@ -3632,6 +3632,10 @@ Val* cast_value_to_type(Val* v, BroType* t)
|
|||
if ( same_type(v->Type(), bro_broker::DataVal::ScriptDataType()) )
|
||||
{
|
||||
auto dv = v->AsRecordVal()->Lookup(0);
|
||||
|
||||
if ( ! dv )
|
||||
return 0;
|
||||
|
||||
return static_cast<bro_broker::DataVal *>(dv)->castTo(t);
|
||||
}
|
||||
|
||||
|
@ -3654,6 +3658,10 @@ bool can_cast_value_to_type(const Val* v, BroType* t)
|
|||
if ( same_type(v->Type(), bro_broker::DataVal::ScriptDataType()) )
|
||||
{
|
||||
auto dv = v->AsRecordVal()->Lookup(0);
|
||||
|
||||
if ( ! dv )
|
||||
return false;
|
||||
|
||||
return static_cast<const bro_broker::DataVal *>(dv)->canCastTo(t);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue