Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PMM-1989 add buf init size in case of slice out of range memory #22

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion query/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ var ReplaceNumbersInWords = false
func Fingerprint(q string) string {
q += " " // need range to run off end of original query
prevWord := ""
f := make([]byte, len(q))
f := make([]byte, len(q)+8)
fi := 0
pr := rune(0) // previous rune
s := unknown // current state
Expand Down
7 changes: 7 additions & 0 deletions query/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,13 @@ func TestFingerprintBasic(t *testing.T) {
"select * from prices.rt_5min where id=?",
query.Fingerprint(q),
)
// Fingerprint Insert into tables;
q = "insert into t3 values(2);"
t.Check(
query.Fingerprint(q),
Equals,
"insert into t3 values(?+);",
)

// Fingerprint /* -- comment */ SELECT (bug 1174956)
q = "/* -- S++ SU ABORTABLE -- spd_user: rspadim */SELECT SQL_SMALL_RESULT SQL_CACHE DISTINCT centro_atividade FROM est_dia WHERE unidade_id=1001 AND item_id=67 AND item_id_red=573"
Expand Down