Skip to content

Commit

Permalink
decoding: always clone strings. fixes #508
Browse files Browse the repository at this point in the history
  • Loading branch information
asdine committed Nov 26, 2023
1 parent acfecdc commit 84a6c9e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/database/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package database

import (
"encoding/binary"
"strings"

"github.com/cockroachdb/errors"
"github.com/genjidb/genji/document"
Expand Down Expand Up @@ -190,6 +191,11 @@ func (e *EncodedDocument) decodeValue(fc *FieldConstraint, b []byte) (types.Valu
}
}

if v.Type() == types.TextValue {
s := strings.Clone(types.As[string](v))
v = types.NewTextValue(s)
}

return v, n, nil
}

Expand Down

0 comments on commit 84a6c9e

Please sign in to comment.