浏览代码

Avoid panic in BytesTo func

RPRX 4 年之前
父节点
当前提交
c880b916ee
共有 1 个文件被更改,包括 3 次插入0 次删除
  1. 3 0
      common/buf/buffer.go

+ 3 - 0
common/buf/buffer.go

@@ -110,6 +110,9 @@ func (b *Buffer) BytesTo(to int32) []byte {
 	if to < 0 {
 	if to < 0 {
 		to += b.Len()
 		to += b.Len()
 	}
 	}
+	if to < 0 {
+		to = 0
+	}
 	return b.v[b.start : b.start+to]
 	return b.v[b.start : b.start+to]
 }
 }