Skip to content

Commit

Permalink
Merge pull request #286 from epage/crash
Browse files Browse the repository at this point in the history
fix(cli): Don't crash on races
  • Loading branch information
epage authored Jun 15, 2021
2 parents 5304d94 + 655b657 commit 1049727
Showing 2 changed files with 10 additions and 15 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
<!-- next-header -->
## [Unreleased] - ReleaseDate

#### Bug Fixes

- Fix a crash from hitting a race condition

## [1.0.8] - 2021-06-15

## [1.0.7] - 2021-06-15
21 changes: 6 additions & 15 deletions src/bin/typos-cli/report.rs
Original file line number Diff line number Diff line change
@@ -59,21 +59,12 @@ impl<'r> MessageStatus<'r> {

impl<'r> Report for MessageStatus<'r> {
fn report(&self, msg: Message) -> Result<(), std::io::Error> {
let _ = self.typos_found.compare_exchange(
false,
msg.is_correction(),
atomic::Ordering::Relaxed,
atomic::Ordering::Relaxed,
);
let _ = self
.errors_found
.compare_exchange(
false,
msg.is_error(),
atomic::Ordering::Relaxed,
atomic::Ordering::Relaxed,
)
.unwrap();
if msg.is_correction() {
self.typos_found.store(true, atomic::Ordering::Relaxed);
}
if msg.is_error() {
self.errors_found.store(true, atomic::Ordering::Relaxed);
}
self.reporter.report(msg)
}
}

0 comments on commit 1049727

Please # to comment.