瀏覽代碼

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 3429e9993085520ac902fef2ef6aabd57080bd36)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Iskander (Alex) Sharipov 6 年之前
父節點
當前提交
1c755a73bf
共有 1 個文件被更改,包括 2 次插入1 次删除
  1. 2 1
      image/rootfs.go

+ 2 - 1
image/rootfs.go

@@ -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
 }