Skip to content

Commit

Permalink
Fixed an out of bounds error in cargo-insta
Browse files Browse the repository at this point in the history
  • Loading branch information
mitsuhiko committed Jul 23, 2022
1 parent 8f659ec commit cae792f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

All notable changes to insta and cargo-insta are documented here.

## 0.17.0

- Fixed an issue in `cargo-insta` where sometimes accepting inline snapshots
would crash with an out of bounds panic.

## 1.16.0

- Added `--no-quiet`/`-Q` flag to `cargo insta test` to suppress the
Expand Down
6 changes: 5 additions & 1 deletion cargo-insta/src/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,11 @@ impl FilePatcher {
tokens: &[TokenTree],
indentation: usize,
) -> bool {
match &tokens[tokens.len() - 2] {
if tokens.len() < 2 {
return false;
}

match tokens[tokens.len() - 2] {
TokenTree::Punct(ref punct) if punct.as_char() == '@' => {}
_ => {
return false;
Expand Down

0 comments on commit cae792f

Please sign in to comment.