Changeset 0.22.0 (#93)
This commit is contained in:
@@ -46,7 +46,15 @@ func (s *jsonScanner) Scan(src interface{}) error {
|
||||
*s.dest = json.RawMessage("{}")
|
||||
return nil
|
||||
}
|
||||
*s.dest = json.RawMessage(v)
|
||||
// CRITICAL: copy the driver buffer. json.RawMessage(v) aliases the
|
||||
// underlying []byte owned by database/sql. The driver may reuse that
|
||||
// memory on the next rows.Scan() call, corrupting our data after the
|
||||
// fact. This caused intermittent SafeJSON 500s on paginated list
|
||||
// endpoints where row N's Settings pointed to row N+1's overwritten
|
||||
// buffer. Fixed in v0.21.7.
|
||||
cp := make([]byte, len(v))
|
||||
copy(cp, v)
|
||||
*s.dest = json.RawMessage(cp)
|
||||
case string:
|
||||
b := []byte(v)
|
||||
if len(b) == 0 || !json.Valid(b) {
|
||||
|
||||
Reference in New Issue
Block a user