Skip to content

Commit 617fb2c

Browse files
committed
cleanup top object list logic in xray
Signed-off-by: Kyle Quest <kcq.public@gmail.com>
1 parent af9f2e1 commit 617fb2c

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

pkg/app/master/command/xray/handler.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1090,7 +1090,13 @@ func printImagePackage(
10901090

10911091
if len(topList) > 0 {
10921092
xc.Out.Info("layer.objects.top.start")
1093-
for _, topObject := range topList {
1093+
for toi, topObject := range topList {
1094+
if topObject == nil {
1095+
log.Errorf("layer.objects.top: skip nil topObject - layer(index=%v/id=%v/path=%s) len(%d) idx(%d)",
1096+
layer.Index, layer.ID, layer.Path, len(topList), toi)
1097+
continue
1098+
}
1099+
10941100
match := topObject.PathMatch
10951101

10961102
if !match && len(changePathMatchers) > 0 {

pkg/docker/dockerimage/topobjects.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ func (to TopObjects) Swap(i, j int) {
2626

2727
func (to *TopObjects) Push(x interface{}) {
2828
item := x.(*ObjectMetadata)
29+
if item == nil {
30+
return
31+
}
2932
*to = append(*to, item)
3033
}
3134

@@ -42,6 +45,9 @@ func (to TopObjects) List() []*ObjectMetadata {
4245
list := []*ObjectMetadata{}
4346
for len(to) > 0 {
4447
item := heap.Pop(&to).(*ObjectMetadata)
48+
if item == nil {
49+
continue
50+
}
4551
list = append([]*ObjectMetadata{item}, list...)
4652
}
4753

0 commit comments

Comments
 (0)