Skip to content

Commit

Permalink
fix: InfiniteTileLayerData index of out bounds (#289)
Browse files Browse the repository at this point in the history
  • Loading branch information
smackysnacks authored May 29, 2024
1 parent fc73d52 commit 4ff6eea
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `ObjectShape::Text::kerning`'s default value, which should have been set to `true` instead of `false`. (#278)
- Unhandled u32 parsing panic in `decode_csv`. (#288)
- Panic in `<Color as FromStr>::from_str` when parsing non-ascii input. (#290)
- Index out of bounds in `InfiniteTileLayerData` when parsing a chunk. (#289)

## [Unreleased]
## Changed
Expand Down
4 changes: 4 additions & 0 deletions src/layers/tile/infinite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ impl InfiniteTileLayerData {
let internal_pos = (x - chunk.x, y - chunk.y);
let internal_index = (internal_pos.0 + internal_pos.1 * chunk.width as i32) as usize;

if internal_index >= chunk.tiles.len() {
return Err(Error::InvalidTileFound);
}

chunks.entry(chunk_pos).or_insert_with(ChunkData::new).tiles[chunk_index] = chunk.tiles[internal_index];
}
}
Expand Down

0 comments on commit 4ff6eea

Please sign in to comment.