Skip to content

Commit

Permalink
add nil guard (#600)
Browse files Browse the repository at this point in the history
  • Loading branch information
goccy authored Dec 20, 2024
1 parent 0c41d8e commit 54cd51f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@ func (d *Decoder) setToOrderedMapValue(node ast.Node, m *MapSlice) error {
}

func (d *Decoder) setPathToCommentMap(node ast.Node) {
if node == nil {
return
}
if d.toCommentMap == nil {
return
}
Expand Down
3 changes: 3 additions & 0 deletions path.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,9 @@ func (p *Path) FilterFile(f *ast.File) (ast.Node, error) {

// FilterNode filter from node by YAMLPath.
func (p *Path) FilterNode(node ast.Node) (ast.Node, error) {
if node == nil {
return nil, nil
}
n, err := p.node.filter(node)
if err != nil {
return nil, err
Expand Down

0 comments on commit 54cd51f

Please sign in to comment.