Fix possible read past the end of the buffer when reading 0 bits.