Skip to content

Commit

Permalink
[sqltypes] no value buffer leakage
Browse files Browse the repository at this point in the history
  • Loading branch information
max-hoffman committed Dec 20, 2024
1 parent b00987f commit b18f18d
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions go/sqltypes/value.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@ limitations under the License.
package sqltypes

import (
"bytes"
"encoding/base64"
"encoding/json"
"fmt"
"strconv"

"github.com/dolthub/vitess/go/bytes2"
"github.com/dolthub/vitess/go/hack"

querypb "github.com/dolthub/vitess/go/vt/proto/query"
)

Expand Down Expand Up @@ -209,7 +208,7 @@ func (v Value) ToString() string {
if v.typ == Expression {
return ""
}
return hack.String(v.val)
return string(v.val)
}

// String returns a printable version of the value.
Expand All @@ -220,7 +219,7 @@ func (v Value) String() string {
if v.IsQuoted() || v.typ == Bit {
return fmt.Sprintf("%v(%q)", v.typ, v.val)
}
return fmt.Sprintf("%v(%s)", v.typ, v.val)
return fmt.Sprintf("%v(%s)", v.typ, bytes.Clone(v.val))
}

// EncodeSQL encodes the value into an SQL statement. Can be binary.
Expand Down

0 comments on commit b18f18d

Please sign in to comment.