Skip to content

Commit

Permalink
fix panic when checking len on nil object
Browse files Browse the repository at this point in the history
issue #7444 describes a problem where an image does not have a manifest file and cannot be processed by our library correctly.  the origin of the panic is because we are checking the len of a nil object's attribute.  this is a temporary fix to protect from the panic in the future.  the origin of the problem is more interesting and requires more work when the code author returns from pto.

Signed-off-by: Brent Baude <[email protected]>
  • Loading branch information
baude committed Aug 28, 2020
1 parent e3edb7b commit a6f8586
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion libpod/image/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -1246,7 +1246,12 @@ func areParentAndChild(parent, child *imgspecv1.Image) bool {
// the child and candidate parent should share all of the
// candidate parent's diff IDs, which together would have
// controlled which layers were used
if len(parent.RootFS.DiffIDs) > len(child.RootFS.DiffIDs) {

// issue #7444 describes a panic where the length of child.RootFS.DiffIDs
// is checked but child is nil. Adding a simple band-aid approach to prevent
// the problem until the origin of the problem can be worked out in the issue
// itself.
if child == nil || len(parent.RootFS.DiffIDs) > len(child.RootFS.DiffIDs) {
return false
}
childUsesCandidateDiffs := true
Expand Down

0 comments on commit a6f8586

Please sign in to comment.