mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
ScriptOpt: Ensure global statements have non-null scope
The ProfileFunc() logic assumed that GetScope() returned a non-nullptr. This holds except for the synthetic global statements function. Fix the latter and add an assert, also add a name to the type so it's easier to recognize in a debugger what's going on, otherwise the name is "". This was found by UBSAN due to it seeing the ->OrderedVars() call on a nullptr. Elsewhere, num_params == 0 shielded from that access and so didn't lead to crashes.
This commit is contained in:
parent
ec1088c3ef
commit
9d1d4e28b3
2 changed files with 4 additions and 0 deletions
|
@ -80,6 +80,8 @@ ProfileFunc::ProfileFunc(const Expr* e, bool _abs_rec_fields) {
|
|||
void ProfileFunc::Profile(const FuncType* ft, const StmtPtr& body) {
|
||||
num_params = ft->Params()->NumFields();
|
||||
|
||||
assert(profiled_scope != nullptr);
|
||||
|
||||
auto& ov = profiled_scope->OrderedVars();
|
||||
for ( int i = 0; i < num_params; ++i )
|
||||
params.insert(ov[i].get());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue