We would always copy sizeof(sorted_position) bytes, which is for 8 channels, but if we have less than 8 channels the position array we copy from will only have allocated space for channel channels, so we would read beyond the input array in some cases.