Bläddra i källkod

Avoid panic in BytesTo func

RPRX 4 år sedan
förälder
incheckning
c880b916ee
1 ändrade filer med 3 tillägg och 0 borttagningar
  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 {
 		to += b.Len()
 	}
+	if to < 0 {
+		to = 0
+	}
 	return b.v[b.start : b.start+to]
 }