Skip to content

Commit 8264272

Browse files
committed
fix preallocations of quoted string
1 parent e5053ee commit 8264272

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

internal/sanitize/sanitize.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ func QuoteString(dst []byte, str string) []byte {
151151

152152
dst = append(dst, quote...)
153153

154-
p := slices.Grow(dst[len(dst):], len(str)+2*n)
154+
p := slices.Grow(dst[len(dst):], 2*len(quote)+len(str)+2*n)
155155

156156
for len(str) > 0 {
157157
i := strings.Index(str, quote)

internal/sanitize/sanitize_fuzz_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package sanitize_test
22

33
import (
4+
"strings"
45
"testing"
56

67
"github.com/jackc/pgx/v5/internal/sanitize"

0 commit comments

Comments
 (0)