Skip to content

Commit

Permalink
fix: add protected code for nil pointer
Browse files Browse the repository at this point in the history
Signed-off-by: zongz <[email protected]>
  • Loading branch information
zong-zhe committed Sep 6, 2024
1 parent 5b65ed4 commit 6fe8066
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/client/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,18 @@ func (c *KpmClient) Update(options ...UpdateOption) (*pkg.KclPkg, error) {
}

kpkg := opts.kpkg
if kpkg == nil {
return nil, fmt.Errorf("kcl package is nil")
}

modDeps := kpkg.ModFile.Dependencies.Deps
if modDeps == nil {
return nil, fmt.Errorf("kcl.mod dependencies is nil")
}
lockDeps := kpkg.Dependencies.Deps
if lockDeps == nil {
return nil, fmt.Errorf("kcl.mod.lock dependencies is nil")
}

// Create a new dependency resolver
resolver := NewDepsResolver(c)
Expand Down

0 comments on commit 6fe8066

Please sign in to comment.