mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
gen-zam: fix memory management for vector-of-strings operations
This commit is contained in:
parent
f330505e83
commit
789b06b1ea
1 changed files with 17 additions and 2 deletions
|
@ -1390,9 +1390,24 @@ void ZAM_ExprOpTemplate::InstantiateEval(const vector<ZAM_OperandType>& ot_orig,
|
||||||
if ( ! is_none && ! is_default && find_type_info(ei.LHS_ET()).is_managed &&
|
if ( ! is_none && ! is_default && find_type_info(ei.LHS_ET()).is_managed &&
|
||||||
! HasExplicitResultType() )
|
! HasExplicitResultType() )
|
||||||
{
|
{
|
||||||
auto delim = zc == ZIC_VEC ? "->" : ".";
|
auto pre = "auto hold_lhs = " + lhs;
|
||||||
auto pre = "auto hold_lhs = " + lhs + delim + "ManagedVal();\n\t";
|
|
||||||
|
if ( zc == ZIC_VEC )
|
||||||
|
// For vectors, we have to check for whether
|
||||||
|
// the previous value is present, or a hole.
|
||||||
|
pre += string(" ? ") + lhs + "->";
|
||||||
|
else
|
||||||
|
pre += ".";
|
||||||
|
|
||||||
|
pre += "ManagedVal()";
|
||||||
|
|
||||||
|
if ( zc == ZIC_VEC )
|
||||||
|
pre += " : nullptr";
|
||||||
|
|
||||||
|
pre += ";\n\t";
|
||||||
|
|
||||||
auto post = "\tUnref(hold_lhs);";
|
auto post = "\tUnref(hold_lhs);";
|
||||||
|
|
||||||
eval = pre + eval + post;
|
eval = pre + eval + post;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue