Skip to content

Commit 794ec0e

Browse files
authored
chore: k way merge sort add boundary check to prevent process crash (#16934)
assert Signed-off-by: coldWater <[email protected]>
1 parent 7b98a13 commit 794ec0e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/query/pipeline/transforms/src/processors/transforms/sort/k_way_merge_sort_partition.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,15 @@ impl<R: Rows> List for Option<R> {
223223
}
224224

225225
fn cmp_value<'a>(&'a self, i: usize, target: &R::Item<'a>) -> Ordering {
226-
self.as_ref().unwrap().row(i).cmp(target)
226+
let rows = self.as_ref().unwrap();
227+
assert!(i < rows.len(), "len {}, index {}", rows.len(), i);
228+
rows.row(i).cmp(target)
227229
}
228230

229231
fn index(&self, i: usize) -> R::Item<'_> {
230-
self.as_ref().unwrap().row(i)
232+
let rows = self.as_ref().unwrap();
233+
assert!(i < rows.len(), "len {}, index {}", rows.len(), i);
234+
rows.row(i)
231235
}
232236
}
233237

0 commit comments

Comments
 (0)