Skip to content

Commit ab6e795

Browse files
committed
Fix buffer overwrite when emitting TIME(0) datatype
1 parent 537893a commit ab6e795

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

types.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -915,8 +915,10 @@ func decodeTime(scale uint8, buf []byte) time.Time {
915915

916916
func encodeTime(hour, minute, second, ns, scale int) (buf []byte) {
917917
seconds := hour*3600 + minute*60 + second
918-
buf = make([]byte, calcTimeSize(scale))
918+
timeSize := calcTimeSize(scale)
919+
buf = make([]byte, timeSize+2)
919920
encodeTimeInt(seconds, ns, scale, buf)
921+
buf = buf[:timeSize]
920922
return
921923
}
922924

0 commit comments

Comments
 (0)