浏览代码

Fix number reads bytes fir mysql 5.6

There is fix situation then mysql return 0 bytes for NULL column. This situation can be called with run statement "show slave hosts" at mysql 5.6 with slave mysql 5.5. In this case we got panic: out of range
Stanislav Putrya 10 年之前
父节点
当前提交
9d0de8723f
共有 1 个文件被更改,包括 3 次插入0 次删除
  1. 3 0
      utils.go

+ 3 - 0
utils.go

@@ -777,6 +777,9 @@ func skipLengthEncodedString(b []byte) (int, error) {
 
 // returns the number read, whether the value is NULL and the number of bytes read
 func readLengthEncodedInteger(b []byte) (uint64, bool, int) {
+	if len(b) == 0 {
+		return 0, true, 1
+	}
 	switch b[0] {
 
 	// 251: NULL