Skip to content

Commit d307af8

Browse files
authored
GODRIVER-2311 Ensure unmarshaled BSON values always use distinct underlying byte arrays. (#874)
1 parent 34db320 commit d307af8

File tree

3 files changed

+346
-5
lines changed

3 files changed

+346
-5
lines changed

bson/bsonrw/value_reader.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,11 @@ func (vr *valueReader) readBytes(length int32) ([]byte, error) {
748748

749749
start := vr.offset
750750
vr.offset += int64(length)
751-
return vr.d[start : start+int64(length)], nil
751+
752+
b := make([]byte, length)
753+
copy(b, vr.d[start:start+int64(length)])
754+
755+
return b, nil
752756
}
753757

754758
func (vr *valueReader) appendBytes(dst []byte, length int32) ([]byte, error) {

0 commit comments

Comments
 (0)