seiflotfy / cuckoofilter

Cuckoo Filter: Practically Better Than Bloom
MIT License
1.11k stars 107 forks source link

Decode([]byte("")) cause panic: runtime error: index out of range [3532051776] with length 0 #45

Closed Isites closed 2 years ago

Isites commented 2 years ago

The following cases were found during online use:

func TestService_getInstalledApps(t *testing.T) {
    c, err := cuckoo.Decode([]byte(""))
    assert.Nil(t, err)
    assert.False(t, c.Lookup([]byte("test")))
}

output:

--- FAIL: TestService_getInstalledApps (0.00s)
panic: runtime error: index out of range [3532051776] with length 0 [recovered]
    panic: runtime error: index out of range [3532051776] with length 0

goroutine 19 [running]:
testing.tRunner.func1.2({0x102e36060, 0x140000e4240})
    /usr/local/go/src/testing/testing.go:1209 +0x258
testing.tRunner.func1(0x140000fe680)
    /usr/local/go/src/testing/testing.go:1212 +0x284
panic({0x102e36060, 0x140000e4240})
    /usr/local/go/src/runtime/panic.go:1038 +0x21c