Skip to content

Commit

Permalink
Merge pull request #29 from sudo-bmitch/pr-index-add-fix
Browse files Browse the repository at this point in the history
Fix Index.AddDesc end of slice panic
  • Loading branch information
sudo-bmitch committed Dec 23, 2023
2 parents f4bae9d + 8518523 commit bec90e3
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions types/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,18 +156,15 @@ func (i *Index) AddDesc(d Descriptor, opts ...IndexOpt) {
}
// search for another descriptor to untag and referrers to delete
if tag != "" || referrer != "" {
mi := len(i.Manifests) - 1
for mi >= 0 {
for mi := len(i.Manifests) - 1; mi >= 0; mi-- {
if i.Manifests[mi].Digest != d.Digest && i.Manifests[mi].Annotations != nil {
if i.Manifests[mi].Annotations[AnnotRefName] == tag {
delete(i.Manifests[mi].Annotations, AnnotRefName)
}
if i.Manifests[mi].Annotations[AnnotReferrerSubject] == referrer {
i.Manifests = append(i.Manifests[:mi], i.Manifests[mi+1:]...)
continue
}
}
mi--
}
}
// remove child entry if found
Expand Down

0 comments on commit bec90e3

Please sign in to comment.