mirror of
https://github.com/zeek/zeek.git
synced 2025-10-05 16:18:19 +00:00
Merge remote-tracking branch 'origin/fastpath'
* origin/fastpath: Fix reference counting for lookup_ID() usages.
This commit is contained in:
commit
a9eb31b461
10 changed files with 49 additions and 9 deletions
4
CHANGES
4
CHANGES
|
@ -1,4 +1,8 @@
|
|||
|
||||
2.2-397 | 2014-05-01 20:29:20 -0700
|
||||
|
||||
* Fix reference counting for lookup_ID() usages. (Jon Siwek)
|
||||
|
||||
2.2-395 | 2014-05-01 20:25:48 -0700
|
||||
|
||||
* Fix missing "irc-dcc-data" service field from IRC DCC connections.
|
||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
2.2-395
|
||||
2.2-397
|
||||
|
|
|
@ -192,6 +192,7 @@ static void parse_function_name(vector<ParseLocationRec>& result,
|
|||
string fullname = make_full_var_name(current_module.c_str(), s.c_str());
|
||||
debug_msg("Function %s not defined.\n", fullname.c_str());
|
||||
plr.type = plrUnknown;
|
||||
Unref(id);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -199,6 +200,7 @@ static void parse_function_name(vector<ParseLocationRec>& result,
|
|||
{
|
||||
debug_msg("Function %s not declared.\n", id->Name());
|
||||
plr.type = plrUnknown;
|
||||
Unref(id);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -206,6 +208,7 @@ static void parse_function_name(vector<ParseLocationRec>& result,
|
|||
{
|
||||
debug_msg("Function %s declared but not defined.\n", id->Name());
|
||||
plr.type = plrUnknown;
|
||||
Unref(id);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -216,9 +219,12 @@ static void parse_function_name(vector<ParseLocationRec>& result,
|
|||
{
|
||||
debug_msg("Function %s is a built-in function\n", id->Name());
|
||||
plr.type = plrUnknown;
|
||||
Unref(id);
|
||||
return;
|
||||
}
|
||||
|
||||
Unref(id);
|
||||
|
||||
Stmt* body = 0; // the particular body we care about; 0 = all
|
||||
|
||||
if ( bodies.size() == 1 )
|
||||
|
|
|
@ -39,7 +39,10 @@ FuncType* EventHandler::FType()
|
|||
if ( id->Type()->Tag() != TYPE_FUNC )
|
||||
return 0;
|
||||
|
||||
return type = id->Type()->AsFuncType();
|
||||
type = id->Type()->AsFuncType();
|
||||
Unref(id);
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
void EventHandler::SetLocalHandler(Func* f)
|
||||
|
|
|
@ -475,6 +475,7 @@ BuiltinFunc::BuiltinFunc(built_in_func arg_func, const char* arg_name,
|
|||
|
||||
type = id->Type()->Ref();
|
||||
id->SetVal(new Val(this));
|
||||
Unref(id);
|
||||
}
|
||||
|
||||
BuiltinFunc::~BuiltinFunc()
|
||||
|
|
|
@ -1286,7 +1286,10 @@ static Val* get_bro_val(const char* label)
|
|||
return 0;
|
||||
}
|
||||
|
||||
return id->ID_Val();
|
||||
Val* rval = id->ID_Val();
|
||||
Unref(id);
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -62,6 +62,7 @@ protected:
|
|||
extern bool in_debug;
|
||||
|
||||
// If no_global is true, don't search in the default "global" namespace.
|
||||
// This passed ownership of a ref'ed ID to the caller.
|
||||
extern ID* lookup_ID(const char* name, const char* module,
|
||||
bool no_global = false, bool same_module_only=false);
|
||||
extern ID* install_ID(const char* name, const char* module_name,
|
||||
|
|
|
@ -1449,6 +1449,7 @@ void EnumType::CheckAndAddName(const string& module_name, const char* name,
|
|||
}
|
||||
else
|
||||
{
|
||||
Unref(id);
|
||||
reporter->Error("identifier or enumerator value in enumerated type definition already exists");
|
||||
SetError();
|
||||
return;
|
||||
|
|
21
src/Var.cc
21
src/Var.cc
|
@ -385,6 +385,8 @@ void begin_func(ID* id, const char* module_name, function_flavor flavor,
|
|||
if ( arg_id && ! arg_id->IsGlobal() )
|
||||
arg_id->Error("argument name used twice");
|
||||
|
||||
Unref(arg_id);
|
||||
|
||||
arg_id = install_ID(arg_i->id, module_name, false, false);
|
||||
arg_id->SetType(arg_i->type->Ref());
|
||||
}
|
||||
|
@ -442,10 +444,13 @@ void end_func(Stmt* body, attr_list* attrs)
|
|||
Val* internal_val(const char* name)
|
||||
{
|
||||
ID* id = lookup_ID(name, GLOBAL_MODULE_NAME);
|
||||
|
||||
if ( ! id )
|
||||
reporter->InternalError("internal variable %s missing", name);
|
||||
|
||||
return id->ID_Val();
|
||||
Val* rval = id->ID_Val();
|
||||
Unref(id);
|
||||
return rval;
|
||||
}
|
||||
|
||||
Val* internal_const_val(const char* name)
|
||||
|
@ -457,13 +462,17 @@ Val* internal_const_val(const char* name)
|
|||
if ( ! id->IsConst() )
|
||||
reporter->InternalError("internal variable %s is not constant", name);
|
||||
|
||||
return id->ID_Val();
|
||||
Val* rval = id->ID_Val();
|
||||
Unref(id);
|
||||
return rval;
|
||||
}
|
||||
|
||||
Val* opt_internal_val(const char* name)
|
||||
{
|
||||
ID* id = lookup_ID(name, GLOBAL_MODULE_NAME);
|
||||
return id ? id->ID_Val() : 0;
|
||||
Val* rval = id ? id->ID_Val() : 0;
|
||||
Unref(id);
|
||||
return rval;
|
||||
}
|
||||
|
||||
double opt_internal_double(const char* name)
|
||||
|
@ -503,6 +512,8 @@ ListVal* internal_list_val(const char* name)
|
|||
return 0;
|
||||
|
||||
Val* v = id->ID_Val();
|
||||
Unref(id);
|
||||
|
||||
if ( v )
|
||||
{
|
||||
if ( v->Type()->Tag() == TYPE_LIST )
|
||||
|
@ -528,7 +539,9 @@ BroType* internal_type(const char* name)
|
|||
if ( ! id )
|
||||
reporter->InternalError("internal type %s missing", name);
|
||||
|
||||
return id->Type();
|
||||
BroType* rval = id->Type();
|
||||
Unref(id);
|
||||
return rval;
|
||||
}
|
||||
|
||||
Func* internal_func(const char* name)
|
||||
|
|
12
src/scan.l
12
src/scan.l
|
@ -606,22 +606,30 @@ void do_atifdef(const char* id)
|
|||
{
|
||||
++current_depth;
|
||||
|
||||
if ( ! lookup_ID(id, current_module.c_str()) )
|
||||
ID* i;
|
||||
|
||||
if ( ! (i = lookup_ID(id, current_module.c_str())) )
|
||||
{
|
||||
if_stack.append(current_depth);
|
||||
BEGIN(IGNORE);
|
||||
}
|
||||
|
||||
Unref(i);
|
||||
}
|
||||
|
||||
void do_atifndef(const char *id)
|
||||
{
|
||||
++current_depth;
|
||||
|
||||
if ( lookup_ID(id, current_module.c_str()) )
|
||||
ID* i;
|
||||
|
||||
if ( (i = lookup_ID(id, current_module.c_str())) )
|
||||
{
|
||||
if_stack.append(current_depth);
|
||||
BEGIN(IGNORE);
|
||||
}
|
||||
|
||||
Unref(i);
|
||||
}
|
||||
|
||||
void do_atelse()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue