mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 09:53:48 +00:00
compression/rle: fix a bug in func "Compress"
This commit is contained in:
parent
a095b84ec5
commit
0aea942be3
2 changed files with 8 additions and 1 deletions
|
|
@ -68,7 +68,7 @@ func compressChunk(dat []byte) (ret []byte, n int) {
|
|||
return []byte{token, tokenToken}, 1
|
||||
case len(dat) > 1 && dat[0] == 0x0 && dat[1] == 0x0:
|
||||
j := 0
|
||||
for j <= 254 && j < len(dat) {
|
||||
for j <= 249 && j < len(dat) {
|
||||
if dat[j] != 0 {
|
||||
break
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,3 +48,10 @@ func (s *CompressionRleSuite) TestDecompressSimple(c *checker.C) {
|
|||
c.Assert(res, checker.DeepEquals, make([]byte, 10))
|
||||
|
||||
}
|
||||
|
||||
func (s *CompressionRleSuite) TestIdentity(c *checker.C) {
|
||||
var exp []byte = make([]byte, 251)
|
||||
res, err := Decompress(Compress(exp))
|
||||
c.Assert(err, checker.IsNil)
|
||||
c.Assert(res, checker.DeepEquals, exp)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue