From 8cd41468c0ba5c4a8a7ca70b6c9141d6131db1c1 Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Wed, 27 May 2020 14:58:16 -0700 Subject: [PATCH] cache: avoid nil dereference Signed-off-by: Tonis Tiigi --- cache/refs.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cache/refs.go b/cache/refs.go index 91e41b142855..d932f4e96c04 100644 --- a/cache/refs.go +++ b/cache/refs.go @@ -180,7 +180,10 @@ func (cr *cacheRecord) Size(ctx context.Context) (int64, error) { cr.mu.Unlock() return usage.Size, nil }) - return s.(int64), err + if err != nil { + return 0, err + } + return s.(int64), nil } func (cr *cacheRecord) Parent() ImmutableRef {