Skip to content

Commit 06afd28

Browse files
committed
fix(cargo): SCA-252 correct visited map update logic in dependency tree building
1 parent fd4fd62 commit 06afd28

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

module/cargo/cargo_lock.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ func analyzeCargoLock(input []byte) (rs []*model.DependencyItem, err error) {
106106
}
107107

108108
func _buildTree(lock map[[2]string][][2]string, key [2]string, visited map[[2]string]struct{}) *model.DependencyItem {
109-
visited[key] = struct{}{}
110109
item, ok := lock[key]
111110
if !ok {
112111
return nil
@@ -122,7 +121,7 @@ func _buildTree(lock map[[2]string][][2]string, key [2]string, visited map[[2]st
122121
if _, ok := visited[key]; ok {
123122
return r
124123
}
125-
124+
visited[key] = struct{}{}
126125
for _, dep := range item {
127126
c := _buildTree(lock, dep, visited)
128127
if c == nil {

0 commit comments

Comments
 (0)