Skip to content

Commit 16e9893

Browse files
committed
fix: check snapshot labels to avoid panic
I saw a panic while using the stargz snapshotter caused by the labels being nil. This adds a check to prevent the panic. Signed-off-by: Chris Goller <[email protected]>
1 parent 6ae419d commit 16e9893

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

cache/refs.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,8 +1099,10 @@ func (sr *immutableRef) prepareRemoteSnapshotsStargzMode(ctx context.Context, s
10991099
if err == nil { // usable as remote snapshot without unlazying.
11001100
defer func() {
11011101
// Remove tmp labels appended in this func
1102-
for k := range tmpLabels {
1103-
info.Labels[k] = ""
1102+
if info.Labels != nil {
1103+
for k := range tmpLabels {
1104+
info.Labels[k] = ""
1105+
}
11041106
}
11051107
if _, err := r.cm.Snapshotter.Update(ctx, info, tmpFields...); err != nil {
11061108
bklog.G(ctx).Warn(errors.Wrapf(err,

0 commit comments

Comments
 (0)