Ensure Printer buf is always indexed using self.left or self.right

This commit is contained in:
David Tolnay 2022-01-18 19:18:04 -08:00
parent ae28ec5a9c
commit 80139a0f02
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
1 changed files with 3 additions and 3 deletions

View File

@ -336,9 +336,9 @@ impl Printer {
fn check_stream(&mut self) { fn check_stream(&mut self) {
if self.right_total - self.left_total > self.space { if self.right_total - self.left_total > self.space {
if Some(&self.left) == self.scan_stack.back() { if self.scan_stack.back() == Some(&self.left) {
let scanned = self.scan_stack.pop_back().unwrap(); self.scan_stack.pop_back().unwrap();
self.buf[scanned].size = SIZE_INFINITY; self.buf[self.left].size = SIZE_INFINITY;
} }
self.advance_left(); self.advance_left();
if self.left != self.right { if self.left != self.right {