layout.pages.insert: range-check the count before narrowing to usize

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Brandon Thomas
2026-10-23 17:18:46 -04:00
co-authored by Claude Opus 5.5
parent 2946f2af62
commit 253be57a85
+1 -1
View File
@@ -120,7 +120,7 @@ pub fn specs() -> Vec<CommandSpec> {
// `0`, `-1` and `1.5` all came out as 1, and 10000 was quietly capped.
let count = match p.get("count").filter(|v| !v.is_null()) {
None => 1,
Some(v) => match v.as_u64().map(|n| n as usize).filter(|n| (1..=9999).contains(n)) {
Some(v) => match v.as_u64().filter(|n| (1..=9999).contains(n)).map(|n| n as usize) {
Some(n) => n,
None => return Err(bad(ID, format!("count {v}: 1 to 9999 pages"))),
},