mirror of
https://github.com/moby/buildkit.git
synced 2026-06-30 19:57:39 +00:00
fix a possible panic on cache
```
newDesc.Annotations = nil
for _, k := range addAnnotations {
newDesc.Annotations[k] = desc.Annotations[k]
}
```
The codes may cause buildkitd panic: assignment to entry in nil map
Signed-off-by: Yan Song <imeoer@linux.alibaba.com>
This commit is contained in:
6
cache/remote.go
vendored
6
cache/remote.go
vendored
@@ -228,13 +228,13 @@ func (sr *immutableRef) getRemote(ctx context.Context, createIfNeeded bool, refC
|
||||
newDesc.Size = blobDesc.Size
|
||||
newDesc.URLs = blobDesc.URLs
|
||||
newDesc.Annotations = nil
|
||||
if len(addAnnotations) > 0 || len(blobDesc.Annotations) > 0 {
|
||||
newDesc.Annotations = make(map[string]string)
|
||||
}
|
||||
for _, k := range addAnnotations {
|
||||
newDesc.Annotations[k] = desc.Annotations[k]
|
||||
}
|
||||
for k, v := range blobDesc.Annotations {
|
||||
if newDesc.Annotations == nil {
|
||||
newDesc.Annotations = make(map[string]string)
|
||||
}
|
||||
newDesc.Annotations[k] = v
|
||||
}
|
||||
desc = newDesc
|
||||
|
||||
Reference in New Issue
Block a user