**Describe the bug**
https://clickhouse-test-reports.s3.yandex.net/19702/c74631c650b42e4d107254a03bd82c2c2913039b/fuzzer_msan/server.log

Most likely introduced here: #11006
}
        if (last - new_first > 1)
        {
            new_ranges.emplace_back(new_first, last);
        }
    }
    if (limit)
    {
        const auto & [first, last] = equal_range.back();
        if (limit < first || limit > last)
            return;
        
        if (reverse)
            partial_sort(res.begin() + first, res.begin() + limit, res.begin() + last, greater(*this, nan_direction_hint));
        else
            partial_sort(res.begin() + first, res.begin() + limit, res.begin() + last, less(*this, nan_direction_hint));
        size_t new_first = first;
        for (size_t j = first + 1; j < limit; ++j)
        {
            if (less(*this, nan_direction_hint)(res[j], res[new_first]) || greater(*this, nan_direction_hint)(res[j], res[new_first]))
            {
                if (j - new_first > 1)
                {
                    new_ranges.emplace_back(new_first, j);
                }
                new_first = j;
            }
        }
        size_t new_last = limit;
        for (size_t j = limit; j < last; ++j)