Skip to content

Commit

Permalink
fix: panic in forEachResult.add
Browse files Browse the repository at this point in the history
  • Loading branch information
jaspervdj-snyk committed Mar 22, 2024
1 parent d867732 commit 22702ee
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pkg/hcl_interpreter/term.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,13 @@ type forEachResult struct {

func (acc *forEachResult) add(key cty.Value, val cty.Value) {
if !acc.isTuple && key.Type() == cty.String {
if acc.object == nil {
acc.object = map[string]cty.Value{}
if !key.IsNull() && key.IsKnown() {
if acc.object == nil {
acc.object = map[string]cty.Value{}
}
acc.object[key.AsString()] = val
acc.tuple = append(acc.tuple, val)
}
acc.object[key.AsString()] = val
acc.tuple = append(acc.tuple, val)
} else {
acc.isTuple = true
acc.tuple = append(acc.tuple, val)
Expand Down

0 comments on commit 22702ee

Please sign in to comment.