In some cases, matchlength is larger than offset. Therefore, match_pos + matchlength > current_pos, which means that later bytes to copy are not yet decoded. This is called an "overlap match", and must be handled with special care. A common case is an offset of 1, meaning the last byte is repeated matchlength times.
const uint8_t *copy_src = out - copy_off;
while(copy_len-- > 0) *out++ = *copy_src++;