Skip to content

Commit dd35a12

Browse files
committed
pango: Fix off-by-one in assertion for pango::itemize()
offset+length needs to be less than *or equal* to the total length.
1 parent bbe4d70 commit dd35a12

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pango/src/functions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ pub fn itemize(
109109
"start_index is out of range"
110110
);
111111
assert!(
112-
length >= 0 && start_index.checked_add(length).unwrap() < total_length,
112+
length >= 0 && start_index.checked_add(length).unwrap() <= total_length,
113113
"start_index + length is out of range"
114114
);
115115
unsafe {
@@ -140,7 +140,7 @@ pub fn itemize_with_base_dir(
140140
"start_index is out of range"
141141
);
142142
assert!(
143-
length >= 0 && start_index.checked_add(length).unwrap() < total_length,
143+
length >= 0 && start_index.checked_add(length).unwrap() <= total_length,
144144
"start_index + length is out of range"
145145
);
146146
unsafe {

0 commit comments

Comments
 (0)