diff --git a/cpp/src/lists/dremel.cu b/cpp/src/lists/dremel.cu index cb9cd4293b5..25094536cce 100644 --- a/cpp/src/lists/dremel.cu +++ b/cpp/src/lists/dremel.cu @@ -225,6 +225,7 @@ dremel_data get_dremel_data(column_view h_col, cudf::detail::device_single_thread( [offset_at_level = d_column_offsets.data(), end_idx_at_level = d_column_ends.data(), + level_max = d_column_offsets.size(), col = *d_col] __device__() { auto curr_col = col; size_type off = curr_col.offset(); @@ -239,9 +240,11 @@ dremel_data get_dremel_data(column_view h_col, if (curr_col.type().id() == type_id::LIST) { off = curr_col.child(lists_column_view::offsets_column_index).element(off); end = curr_col.child(lists_column_view::offsets_column_index).element(end); - offset_at_level[level] = off; - end_idx_at_level[level] = end; - ++level; + if (level < level_max) { + offset_at_level[level] = off; + end_idx_at_level[level] = end; + ++level; + } curr_col = curr_col.child(lists_column_view::child_column_index); } else { curr_col = curr_col.child(0);