Skip to content

Commit 70b5820

Browse files
committed
basic checks to avoid nils in top objects
Signed-off-by: Kyle Quest <kcq.public@gmail.com>
1 parent 4432195 commit 70b5820

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pkg/docker/dockerimage/topobjects.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ func NewTopObjects(n int) TopObjects {
1717
func (to TopObjects) Len() int { return len(to) }
1818

1919
func (to TopObjects) Less(i, j int) bool {
20+
if to[i] == nil && to[j] != nil {
21+
return true
22+
}
23+
if to[i] != nil && to[j] == nil {
24+
return false
25+
}
26+
if to[i] == nil && to[j] == nil {
27+
return false
28+
}
29+
2030
return to[i].Size < to[j].Size
2131
}
2232

0 commit comments

Comments
 (0)