mirror of
https://github.com/zeek/zeek.git
synced 2025-10-03 23:28:20 +00:00
BIT-1785: fix scripts able to access uninitialized variables.
This commit is contained in:
parent
3cfe8cd294
commit
c857f5c4dd
5 changed files with 38 additions and 0 deletions
|
@ -33,6 +33,15 @@ Frame::~Frame()
|
||||||
Release();
|
Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Frame::Reset(int startIdx)
|
||||||
|
{
|
||||||
|
for ( int i = startIdx; i < size; ++i )
|
||||||
|
{
|
||||||
|
Unref(frame[i]);
|
||||||
|
frame[i] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Frame::Release()
|
void Frame::Release()
|
||||||
{
|
{
|
||||||
for ( int i = 0; i < size; ++i )
|
for ( int i = 0; i < size; ++i )
|
||||||
|
|
|
@ -24,6 +24,7 @@ public:
|
||||||
frame[n] = v;
|
frame[n] = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Reset(int startIdx);
|
||||||
void Release();
|
void Release();
|
||||||
|
|
||||||
void Describe(ODesc* d) const;
|
void Describe(ODesc* d) const;
|
||||||
|
|
|
@ -397,6 +397,7 @@ Val* BroFunc::Call(val_list* args, Frame* parent) const
|
||||||
bodies[i].stmts->GetLocationInfo());
|
bodies[i].stmts->GetLocationInfo());
|
||||||
|
|
||||||
Unref(result);
|
Unref(result);
|
||||||
|
f->Reset(args->length());
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
2
testing/btest/Baseline/language.uninitialized-local2/out
Normal file
2
testing/btest/Baseline/language.uninitialized-local2/out
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
error in /home/jon/projects/bro/bro/testing/btest/.tmp/language.uninitialized-local2/uninitialized-local2.bro, line 19: value used but not set (var_b)
|
||||||
|
var_a is, baz
|
25
testing/btest/language/uninitialized-local2.bro
Normal file
25
testing/btest/language/uninitialized-local2.bro
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
# @TEST-EXEC: bro -b %INPUT >out 2>&1
|
||||||
|
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out
|
||||||
|
|
||||||
|
event test()
|
||||||
|
{
|
||||||
|
local var_a: string = "foo";
|
||||||
|
}
|
||||||
|
|
||||||
|
event test()
|
||||||
|
{
|
||||||
|
if ( F )
|
||||||
|
{
|
||||||
|
local var_b: string = "bar";
|
||||||
|
}
|
||||||
|
|
||||||
|
local var_a: string = "baz";
|
||||||
|
|
||||||
|
print "var_a is", var_a;
|
||||||
|
print "var_b is", var_b;
|
||||||
|
}
|
||||||
|
|
||||||
|
event bro_init()
|
||||||
|
{
|
||||||
|
event test();
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue