From c28695b9253569683c6e0e5f25a04c0701100b0a Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Fri, 16 Apr 2021 10:42:08 +0200 Subject: Fix possible panic in libpod/image/prune.go podman image prune paniced locally for me. The error handling was not done correctly and we could end up with a nil pointer dereference. [NO TESTS NEEDED] I have no idea how I could force an error in img.Size(). Signed-off-by: Paul Holzinger --- libpod/image/prune.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libpod/image/prune.go b/libpod/image/prune.go index 12727901a..0e41fde44 100644 --- a/libpod/image/prune.go +++ b/libpod/image/prune.go @@ -134,10 +134,11 @@ func (ir *Runtime) PruneImages(ctx context.Context, all bool, filter []string) ( } nameOrID := img.ID() s, err := img.Size(ctx) - imgSize := *s + imgSize := uint64(0) if err != nil { logrus.Warnf("Failed to collect image size for: %s, %s", nameOrID, err) - imgSize = 0 + } else { + imgSize = *s } if err := img.Remove(ctx, false); err != nil { if errors.Cause(err) == storage.ErrImageUsedByContainer { -- cgit v1.2.3-54-g00ecf