diff --git a/cpp/src/reductions/scan.cu b/cpp/src/reductions/scan.cu index 011b34031fe..6c42c8aa3f7 100644 --- a/cpp/src/reductions/scan.cu +++ b/cpp/src/reductions/scan.cu @@ -116,8 +116,9 @@ struct scan_dispatcher { thrust::find_if_not( rmm::exec_policy(stream), v, v + input_view.size(), thrust::identity{}) - v; - cudf::set_null_mask( - static_cast(mask.data()), 0, first_null_position, true); + if (first_null_position > 0) + cudf::set_null_mask( + static_cast(mask.data()), 0, first_null_position, true); cudf::set_null_mask( static_cast(mask.data()), first_null_position, input_view.size(), false); return mask;