Skip to content

Commit 656614d

Browse files
committed
writeExecutePacket: fix capacity check
1 parent ddf24e6 commit 656614d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packets.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,7 @@ func (stmt *mysqlStmt) writeExecutePacket(args []driver.Value) error {
877877
switch v := args[i].(type) {
878878
case int64:
879879
paramTypes[i+i] = fieldTypeLongLong
880-
if cap(paramValues) <= len(paramValues)+8 {
880+
if cap(paramValues)-len(paramValues)-8 >= 0 {
881881
paramValues = paramValues[:len(paramValues)+8]
882882
binary.LittleEndian.PutUint64(paramValues, uint64(v))
883883
} else {
@@ -888,7 +888,7 @@ func (stmt *mysqlStmt) writeExecutePacket(args []driver.Value) error {
888888

889889
case float64:
890890
paramTypes[i+i] = fieldTypeDouble
891-
if cap(paramValues) <= len(paramValues)+8 {
891+
if cap(paramValues)-len(paramValues)-8 >= 0 {
892892
paramValues = paramValues[:len(paramValues)+8]
893893
binary.LittleEndian.PutUint64(paramValues, math.Float64bits(v))
894894
} else {

0 commit comments

Comments
 (0)