fix crash when copy rule points to outside the rule bounds after a resize
This commit is contained in:
parent
17e8291281
commit
99e5388a46
1 changed files with 6 additions and 1 deletions
|
@ -418,7 +418,12 @@ impl Dish {
|
|||
}
|
||||
}
|
||||
RuleCellTo::Copy(x, y) => {
|
||||
let cell = old_state[x + y * variant.width];
|
||||
let index = x + y * variant.width;
|
||||
if index >= old_state.len() {
|
||||
// the copy source is outside the rule bounds
|
||||
continue;
|
||||
}
|
||||
let cell = old_state[index];
|
||||
if let Some(cell) = cell {
|
||||
// if the copy source is outside the world, do nothing
|
||||
self.set_cell(px, py, cell);
|
||||
|
|
Loading…
Reference in a new issue