diff --git a/mysql/mysql_test.go b/mysql/mysql_test.go index f5d7e0624..d3264239b 100644 --- a/mysql/mysql_test.go +++ b/mysql/mysql_test.go @@ -223,3 +223,9 @@ func (t *mysqlTestSuite) TestMysqlUUIDClone(c *check.C) { clone := us.Clone() c.Assert(clone.String(), check.Equals, "de278ad0-2106-11e4-9f8e-6edd0ca20947:1-2") } + +func (t *mysqlTestSuite) TestMysqlEmptyDecode(c *check.C) { + _, isNull, n := LengthEncodedInt(nil) + c.Assert(isNull, check.IsTrue) + c.Assert(n, check.Equals, 0) +} diff --git a/mysql/util.go b/mysql/util.go index 054fe4fe1..0276b65ae 100644 --- a/mysql/util.go +++ b/mysql/util.go @@ -142,7 +142,7 @@ func BFixedLengthInt(buf []byte) uint64 { func LengthEncodedInt(b []byte) (num uint64, isNull bool, n int) { if len(b) == 0 { - return 0, true, 1 + return 0, true, 0 } switch b[0] {