You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fletcher32 raises IndexError on empty buffers #888
Fletcher32 raises IndexError when it encodes an empty buffer, and when it decodes a 4-byte buffer that holds only the checksum. The other checksum codecs (CRC32, Adler32, JenkinsLookup3) round-trip empty input without error.
Reproduce
fromnumcodecsimportFletcher32Fletcher32().encode(b"")
# IndexError: Out of bounds on buffer access (axis 0)Fletcher32().decode(b"\x00\x00\x00\x00")
# IndexError: Out of bounds on buffer access (axis 0)
fletcher32.pyx takes &mv[0] of the payload memoryview in _fletcher32, encode, and the out branch of decode. Cython bounds-checks that index, so it fails when the memoryview is empty.
Expected
An empty payload has a Fletcher-32 checksum of 0, the same result the HDF5/netCDF reference implementation gives for a zero-length input. encode(b"") returns b"\x00\x00\x00\x00", and decoding that buffer returns an empty buffer.
Activity