AutoFill: refuse a source as large as the sheet

The target was capped at 5 million cells but the source wasn't: with the
whole sheet as source and A1 as target, AutoFill read all 17 billion
source cells one column at a time and never finished.
This commit is contained in:
nihilist-narwhal
2026-10-10 03:46:15 -05:00
parent 7fece30d49
commit 60b60619b2
2 changed files with 3 additions and 2 deletions
+2 -2
View File
@@ -1076,8 +1076,8 @@ fn auto_fill(s: &mut Session, p: &Json) -> Result<Json> {
"values" => crate::fill::FillMode::ValuesOnly,
_ => crate::fill::FillMode::Series,
};
if target.count() > 5_000_000 {
return Err(bad("edit.autoFill", "target too large"));
if target.count() > 5_000_000 || src.count() > 5_000_000 {
return Err(bad("edit.autoFill", "range too large"));
}
edit(s, |cx| {
crate::fill::fill(cx, sheet, src, target, mode)?;
+1
View File
@@ -181,6 +181,7 @@ fn whole_sheet_selection_stays_within_the_data() {
s.execute("edit.fillUp", json!({})).unwrap();
assert_eq!(v(&s, "A1"), Value::Number(5.0));
assert!(s.execute("edit.fillDown", json!({"range": "A1:Z1000000"})).is_err(), "too large to fill");
assert!(s.execute("edit.autoFill", json!({"source": "A1:XFD1048576", "target": "A1"})).is_err(), "too large to fill");
s.execute("range.setValues", json!({"range": "D1", "values": [[1], [1], [2]]})).unwrap();
let r = s.execute("data.removeDuplicates", json!({"range": "D:D", "header": false})).unwrap();
assert_eq!((r["removed"].clone(), r["remaining"].clone()), (json!(1), json!(2)));