Skip to content

Commit

Permalink
Merge pull request #392 from dolthub/max/sql-buffer-leak
Browse files Browse the repository at this point in the history
[sqltypes] no value buffer leakage
  • Loading branch information
max-hoffman authored Dec 20, 2024
2 parents b00987f + b18f18d commit 6c50e01
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 6c50e01

Please sign in to comment.