Don't leak containers/image Image references

In-memory image objects created using an ImageReference's NewImage()
method need to be Close()d.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
This commit is contained in:
Nalin Dahyabhai 2017-07-25 13:30:54 -04:00
parent 2e50006f1c
commit 3747048aa4

View file

@ -96,6 +96,7 @@ func matchesLabel(image storage.Image, store storage.Store, label string) bool {
if err != nil { if err != nil {
return false return false
} }
defer img.Close()
info, err := img.Inspect() info, err := img.Inspect()
if err != nil { if err != nil {
return false return false
@ -229,6 +230,7 @@ func Size(store storage.Store, img storage.Image) (int64, error) {
if err != nil { if err != nil {
return -1, err return -1, err
} }
defer imgRef.Close()
imgSize, err := imgRef.Size() imgSize, err := imgRef.Size()
if err != nil { if err != nil {
return -1, err return -1, err