Skip to content

Commit

Permalink
fix: erase_tokens_after not removing some tokens from the LUT
Browse files Browse the repository at this point in the history
`inter::Interner::erase_tokens_after` did not remove some tokens
from its internal LUT in rare cases which could cause panics or
incorrect interning afterwards.
  • Loading branch information
pascalkuthe committed Nov 4, 2022
1 parent b0ba1ed commit 621cd21
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ All notable changes to imara-diff will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.1.4 - 2022-10-26

## 0.1.5 - 2022-11-4

### Fixed

* `inter::Interner::erase_tokens_after` not removing tokens from the LUT in some cases.

## 0.1.4 - 2022-11-4

### Fixed

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "imara-diff"
version = "0.1.4"
version = "0.1.5"
edition = "2021"
authors = ["pascalkuthe <[email protected]>"]
rust-version = "1.61"
Expand Down
2 changes: 1 addition & 1 deletion src/intern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ impl<T: Hash + Eq> Interner<T> {
}
} else {
for (i, token) in self.tokens[retained..].iter().enumerate() {
self.table.erase_entry(self.hasher.hash_one(token), |token| token.0 == i as u32);
self.table.erase_entry(self.hasher.hash_one(token), |token| token.0 == (retained + i) as u32);
}
}
self.tokens.truncate(first_erased_token.0 as usize);
Expand Down

0 comments on commit 621cd21

Please sign in to comment.