From 3747048aa492e7a3c832c97f1828e00fd8c897cc Mon Sep 17 00:00:00 2001 From: Nalin Dahyabhai Date: Tue, 25 Jul 2017 13:30:54 -0400 Subject: [PATCH] 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 --- libkpod/image/image.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libkpod/image/image.go b/libkpod/image/image.go index f2896d17..2a840d50 100644 --- a/libkpod/image/image.go +++ b/libkpod/image/image.go @@ -96,6 +96,7 @@ func matchesLabel(image storage.Image, store storage.Store, label string) bool { if err != nil { return false } + defer img.Close() info, err := img.Inspect() if err != nil { return false @@ -229,6 +230,7 @@ func Size(store storage.Store, img storage.Image) (int64, error) { if err != nil { return -1, err } + defer imgRef.Close() imgSize, err := imgRef.Size() if err != nil { return -1, err