mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Fix buffer aliasing issue when Merging views.
PiperOrigin-RevId: 427662565
This commit is contained in:
committed by
gVisor bot
parent
974c0c2c9a
commit
5a52fcc546
+11
-1
@@ -385,6 +385,10 @@ func (v *View) Clone() View {
|
||||
size: v.size,
|
||||
}
|
||||
for buf := v.data.Front(); buf != nil; buf = buf.Next() {
|
||||
// Copy the buffer structs itself as they are stateful and
|
||||
// should not be shared between Views.
|
||||
//
|
||||
// TODO(gvisor.dev/issue/7158): revisit need for View.pool.
|
||||
newBuf := other.pool.getNoInit()
|
||||
*newBuf = *buf
|
||||
other.data.PushBack(newBuf)
|
||||
@@ -428,7 +432,13 @@ func (v *View) Merge(other *View) {
|
||||
// Copy over all buffers.
|
||||
for buf := other.data.Front(); buf != nil; buf = other.data.Front() {
|
||||
other.data.Remove(buf)
|
||||
v.data.PushBack(buf)
|
||||
// Copy the buffer structs itself as they are stateful and
|
||||
// should not be shared between Views.
|
||||
//
|
||||
// TODO(gvisor.dev/issue/7158): revisit need for View.pool.
|
||||
newBuf := v.pool.getNoInit()
|
||||
*newBuf = *buf
|
||||
v.data.PushBack(newBuf)
|
||||
}
|
||||
|
||||
// Adjust sizes.
|
||||
|
||||
Reference in New Issue
Block a user