Skip to content

Commit

Permalink
Fix another integer overflow in wasmprinter's nesting
Browse files Browse the repository at this point in the history
Don't decrease the current nesting level past where we started in the
case that there's multiple `end` instructions.
  • Loading branch information
alexcrichton committed Oct 21, 2020
1 parent eb55f1c commit 5bf5d9d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion crates/wasmprinter/src/lib.rs
Expand Up @@ -627,7 +627,7 @@ impl Printer {

// Exiting a block prints `end` at the previous indentation
// level.
Operator::End => {
Operator::End if self.nesting > nesting_start => {
self.nesting -= 1;
self.newline();
}
Expand Down
10 changes: 10 additions & 0 deletions crates/wasmprinter/tests/all.rs
Expand Up @@ -9,6 +9,16 @@ fn no_panic() {
)
.unwrap();
wasmprinter::print_bytes(&bytes).unwrap();

let bytes = wat::parse_str(
r#"
(module
(func end)
)
"#,
)
.unwrap();
wasmprinter::print_bytes(&bytes).unwrap();
}

#[test]
Expand Down

0 comments on commit 5bf5d9d

Please sign in to comment.