image: do actual RootFS.DiffIDs copying in Clone()

append(newRoot.DiffIDs) without element does nothing,
so it's probably not what was intended. Changed code
to perform a slice copying instead.

Fixes #38834.

Signed-off-by: Iskander Sharipov <quasilyte@gmail.com>
(cherry picked from commit 3429e99930)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Iskander (Alex) Sharipov 2019-03-08 10:39:58 +03:00 committed by Sebastiaan van Stijn
parent d2cfbce3f3
commit 1c755a73bf
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C

View file

@ -38,7 +38,8 @@ func (r *RootFS) Append(id layer.DiffID) {
func (r *RootFS) Clone() *RootFS {
newRoot := NewRootFS()
newRoot.Type = r.Type
newRoot.DiffIDs = append(r.DiffIDs)
newRoot.DiffIDs = make([]layer.DiffID, len(r.DiffIDs))
copy(newRoot.DiffIDs, r.DiffIDs)
return newRoot
}