Skip to content

Commit

Permalink
fix: json unmarshal
Browse files Browse the repository at this point in the history
 - don't reuse byte slice, but make a copy
  • Loading branch information
Dasio authored and jackc committed Jul 31, 2023
1 parent 53c8e6e commit 9df8472
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions json.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,9 @@ func (dst *JSON) UnmarshalJSON(b []byte) error {
if b == nil || string(b) == "null" {
*dst = JSON{Status: Null}
} else {
*dst = JSON{Bytes: b, Status: Present}
bCopy := make([]byte, len(b))
copy(bCopy, b)
*dst = JSON{Bytes: bCopy, Status: Present}
}
return nil

}

0 comments on commit 9df8472

Please sign in to comment.