Merge pull request #2519 from aaronlehmann/dedup-mounts-panic
Fix out-of-bounds panic in dedupMountsmaster
commit
e89482149f
|
@ -104,11 +104,11 @@ func withBoundProc() oci.SpecOpts {
|
||||||
func dedupMounts(mnts []specs.Mount) []specs.Mount {
|
func dedupMounts(mnts []specs.Mount) []specs.Mount {
|
||||||
ret := make([]specs.Mount, 0, len(mnts))
|
ret := make([]specs.Mount, 0, len(mnts))
|
||||||
visited := make(map[string]int)
|
visited := make(map[string]int)
|
||||||
for i, mnt := range mnts {
|
for _, mnt := range mnts {
|
||||||
if j, ok := visited[mnt.Destination]; ok {
|
if j, ok := visited[mnt.Destination]; ok {
|
||||||
ret[j] = mnt
|
ret[j] = mnt
|
||||||
} else {
|
} else {
|
||||||
visited[mnt.Destination] = i
|
visited[mnt.Destination] = len(ret)
|
||||||
ret = append(ret, mnt)
|
ret = append(ret, mnt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue