diff --git a/src/Frame.cc b/src/Frame.cc index e97b948dbe..f30312aaec 100644 --- a/src/Frame.cc +++ b/src/Frame.cc @@ -33,6 +33,15 @@ Frame::~Frame() Release(); } +void Frame::Reset(int startIdx) + { + for ( int i = startIdx; i < size; ++i ) + { + Unref(frame[i]); + frame[i] = 0; + } + } + void Frame::Release() { for ( int i = 0; i < size; ++i ) diff --git a/src/Frame.h b/src/Frame.h index 85e1dbec2e..0c22fa0e4e 100644 --- a/src/Frame.h +++ b/src/Frame.h @@ -24,6 +24,7 @@ public: frame[n] = v; } + void Reset(int startIdx); void Release(); void Describe(ODesc* d) const; diff --git a/src/Func.cc b/src/Func.cc index ccb2570f70..88da9a7a04 100644 --- a/src/Func.cc +++ b/src/Func.cc @@ -397,6 +397,7 @@ Val* BroFunc::Call(val_list* args, Frame* parent) const bodies[i].stmts->GetLocationInfo()); Unref(result); + f->Reset(args->length()); try { diff --git a/testing/btest/Baseline/language.uninitialized-local2/out b/testing/btest/Baseline/language.uninitialized-local2/out new file mode 100644 index 0000000000..75d09294e6 --- /dev/null +++ b/testing/btest/Baseline/language.uninitialized-local2/out @@ -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 diff --git a/testing/btest/language/uninitialized-local2.bro b/testing/btest/language/uninitialized-local2.bro new file mode 100644 index 0000000000..f11a5fda10 --- /dev/null +++ b/testing/btest/language/uninitialized-local2.bro @@ -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(); + }