Skip to content

Commit

Permalink
internal/core/adt: fix memory leak
Browse files Browse the repository at this point in the history
Also includes some minimal cleanup.

Change-Id: Ie84784a1f6c7137805d6d1461f46d3aee157bfcd
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/8285
Reviewed-by: CUE cueckoo <cueckoo@gmail.com>
Reviewed-by: Paul Jolly <paul@myitcv.org.uk>
  • Loading branch information
mpvl committed Jan 24, 2021
1 parent 0e401d6 commit 9c5489f
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions internal/core/adt/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,20 +392,21 @@ func (e *Unifier) Unify(c *OpContext, v *Vertex, state VertexStatus) {
}

func (n *nodeContext) doNotify() {
if n.errs != nil && len(n.notify) > 0 {
for _, v := range n.notify {
if v.state == nil {
if b, ok := v.BaseValue.(*Bottom); ok {
v.BaseValue = CombineErrors(nil, b, n.errs)
} else {
v.BaseValue = n.errs
}
if n.errs == nil || len(n.notify) == 0 {
return
}
for _, v := range n.notify {
if v.state == nil {
if b, ok := v.BaseValue.(*Bottom); ok {
v.BaseValue = CombineErrors(nil, b, n.errs)
} else {
v.state.addBottom(n.errs)
v.BaseValue = n.errs
}
} else {
v.state.addBottom(n.errs)
}
n.notify = n.notify[:0]
}
n.notify = n.notify[:0]
}

func isStruct(v *Vertex) bool {
Expand Down Expand Up @@ -774,6 +775,7 @@ func (e *Unifier) newNodeContext(ctx *OpContext, node *Vertex) *nodeContext {
node: node,
kind: TopKind,
arcMap: n.arcMap[:0],
notify: n.notify[:0],
checks: n.checks[:0],
dynamicFields: n.dynamicFields[:0],
ifClauses: n.ifClauses[:0],
Expand Down

0 comments on commit 9c5489f

Please sign in to comment.