Skip to content

Commit 153414b

Browse files
authored
fix: make copy of data for ByteString (#130)
Using the original byte slice can cause problems if it's modified elsewhere Signed-off-by: Aurora Gaffney <[email protected]>
1 parent 2aec744 commit 153414b

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

data/data.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,9 @@ func (b ByteString) String() string {
116116

117117
// NewByteString creates a new ByteString variant.
118118
func NewByteString(value []byte) PlutusData {
119-
if value == nil {
120-
value = make([]byte, 0)
121-
}
122-
return &ByteString{value}
119+
tmpVal := make([]byte, len(value))
120+
copy(tmpVal, value)
121+
return &ByteString{tmpVal}
123122
}
124123

125124
// List

0 commit comments

Comments
 (0)