Expr: fix memory leak in RecordCoerceExpr::Fold()

Don't add a second reference if the `rhs` variable was assigned from
`def->AttrExpr()->Eval(0)`.

Caused by commit af3267acc3
This commit is contained in:
Max Kellermann 2020-02-24 13:42:25 +01:00
parent 46ecbd400e
commit e557563c69

View file

@ -3804,8 +3804,7 @@ Val* RecordCoerceExpr::Fold(Val* v) const
if ( def ) if ( def )
rhs = def->AttrExpr()->Eval(0); rhs = def->AttrExpr()->Eval(0);
} }
else
if ( rhs )
rhs = rhs->Ref(); rhs = rhs->Ref();
assert(rhs || Type()->AsRecordType()->FieldDecl(i)->FindAttr(ATTR_OPTIONAL)); assert(rhs || Type()->AsRecordType()->FieldDecl(i)->FindAttr(ATTR_OPTIONAL));