Fixing bug with deleting still unset record fields of table type.

This commit is contained in:
Robin Sommer 2011-04-23 10:38:16 -07:00
parent 59d6202104
commit c41da9ca99
3 changed files with 19 additions and 1 deletions

View file

@ -2883,7 +2883,7 @@ RecordVal::~RecordVal()
void RecordVal::Assign(int field, Val* new_val, Opcode op) void RecordVal::Assign(int field, Val* new_val, Opcode op)
{ {
if ( Lookup(field) && if ( new_val && Lookup(field) &&
record_type->FieldType(field)->Tag() == TYPE_TABLE && record_type->FieldType(field)->Tag() == TYPE_TABLE &&
new_val->AsTableVal()->FindAttr(ATTR_MERGEABLE) ) new_val->AsTableVal()->FindAttr(ATTR_MERGEABLE) )
{ {

View file

@ -0,0 +1 @@
[a=<uninitialized>, b=<uninitialized>, c=<uninitialized>]

View file

@ -0,0 +1,17 @@
# @TEST-EXEC: bro %INPUT >output 2>&1
# @TEST-EXEC: btest-diff output
type FooBar: record {
a: set[string] &default=set();
b: table[string] of count &default=table();
c: vector of string &default=vector();
};
global test: FooBar;
delete test$a;
delete test$b;
delete test$c;
print test;