mirror of
https://github.com/zeek/zeek.git
synced 2025-10-15 21:18:20 +00:00
BIT-1373: fix vector index assignment ref count bug.
This commit is contained in:
parent
fae4ff8da2
commit
bb15754427
1 changed files with 6 additions and 2 deletions
|
@ -2985,8 +2985,10 @@ bool VectorVal::Assign(unsigned int index, Val* element, Opcode op)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Val* val_at_index = 0;
|
||||||
|
|
||||||
if ( index < val.vector_val->size() )
|
if ( index < val.vector_val->size() )
|
||||||
Unref((*val.vector_val)[index]);
|
val_at_index = (*val.vector_val)[index];
|
||||||
else
|
else
|
||||||
val.vector_val->resize(index + 1);
|
val.vector_val->resize(index + 1);
|
||||||
|
|
||||||
|
@ -2999,10 +3001,12 @@ bool VectorVal::Assign(unsigned int index, Val* element, Opcode op)
|
||||||
|
|
||||||
StateAccess::Log(new StateAccess(op == OP_INCR ?
|
StateAccess::Log(new StateAccess(op == OP_INCR ?
|
||||||
OP_INCR_IDX : OP_ASSIGN_IDX,
|
OP_INCR_IDX : OP_ASSIGN_IDX,
|
||||||
this, ival, element, (*val.vector_val)[index]));
|
this, ival, element, val_at_index));
|
||||||
Unref(ival);
|
Unref(ival);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Unref(val_at_index);
|
||||||
|
|
||||||
// Note: we do *not* Ref() the element, if any, at this point.
|
// Note: we do *not* Ref() the element, if any, at this point.
|
||||||
// AssignExpr::Eval() already does this; other callers must remember
|
// AssignExpr::Eval() already does this; other callers must remember
|
||||||
// to do it similarly.
|
// to do it similarly.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue