From d9bfaf51977cdc7088fe168d871ac5ce787c9d6a Mon Sep 17 00:00:00 2001 From: Miloslav Trmač Date: Fri, 7 Feb 2020 02:43:14 +0100 Subject: Create two separate newImage instances in Runtime.New MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is not _trivially_ safe because newImage.getLocalImage() modifies newImage.ImageName, but we overwrite that value anyway. So, this should not change behavior, and it will make future refactoring easier to verify. Signed-off-by: Miloslav Trmač --- libpod/image/image.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'libpod') diff --git a/libpod/image/image.go b/libpod/image/image.go index f773ab74a..28148b7c3 100644 --- a/libpod/image/image.go +++ b/libpod/image/image.go @@ -145,11 +145,11 @@ func (ir *Runtime) New(ctx context.Context, name, signaturePolicyPath, authfile defer span.Finish() // We don't know if the image is local or not ... check local first - newImage := Image{ - InputName: name, - imageruntime: ir, - } if pullType != util.PullImageAlways { + newImage := Image{ + InputName: name, + imageruntime: ir, + } localImage, err := newImage.getLocalImage() if err == nil { newImage.image = localImage @@ -168,6 +168,10 @@ func (ir *Runtime) New(ctx context.Context, name, signaturePolicyPath, authfile return nil, errors.Wrapf(err, "unable to pull %s", name) } + newImage := Image{ + InputName: name, + imageruntime: ir, + } newImage.InputName = imageName[0] img, err := newImage.getLocalImage() if err != nil { -- cgit v1.2.3-54-g00ecf