summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Holzinger <paul.holzinger@web.de>2021-04-16 10:42:08 +0200
committerPaul Holzinger <paul.holzinger@web.de>2021-04-16 11:21:47 +0200
commit12bcfa360d17c6ce40d4fc852b18a901f92c5e75 (patch)
tree6f368d27c056fe901623589d3294189dcee9ec07
parent4c88035f09474a80264400aa825509900100e32e (diff)
downloadpodman-12bcfa360d17c6ce40d4fc852b18a901f92c5e75.tar.gz
podman-12bcfa360d17c6ce40d4fc852b18a901f92c5e75.tar.bz2
podman-12bcfa360d17c6ce40d4fc852b18a901f92c5e75.zip
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 <paul.holzinger@web.de>
-rw-r--r--libpod/image/prune.go5
1 files 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 {