Skip to content

Commit

Permalink
Fix #530 - out of bounds memory writes in valence_anvil (#531)
Browse files Browse the repository at this point in the history
# Objective

- Fixes #530 

# Solution

- Fixed some dumb code I wrote
  • Loading branch information
Earthcomputer authored Sep 20, 2023
1 parent 623392b commit df4f0f6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions crates/valence_anvil/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,7 @@ impl Region {
)
});

let mut used_sectors = bitvec::vec::BitVec::new();
used_sectors[0..2].fill(true);
let mut used_sectors = bitvec::vec::BitVec::repeat(true, 2);
for location in locations {
if location.is_none() {
// No chunk exists at this position.
Expand Down Expand Up @@ -690,6 +689,7 @@ impl Region {
let end_index = sector_offset as usize + sector_count;
if used_sectors.len() < end_index {
used_sectors.resize(start_index, false);
used_sectors.resize(end_index, true);
} else {
used_sectors[start_index..end_index].fill(true);
}
Expand Down

0 comments on commit df4f0f6

Please sign in to comment.