use saturatig_sub() to avoid a negative value causing an overflow panic (#3139)

This commit is contained in:
Antioch Peverell 2019-11-26 19:05:04 +00:00 committed by GitHub
parent 0c6c464e94
commit dcfcd3ee79
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -94,7 +94,7 @@ impl View for LogBufferView {
rows.reverse(); // So stack traces are in the right order. rows.reverse(); // So stack traces are in the right order.
for row in rows { for row in rows {
for span in row.resolve(&log_message) { for span in row.resolve(&log_message) {
p.print((0, p.size.y - 1 - i), span.content); p.print((0, p.size.y.saturating_sub(i + 1)), span.content);
i += 1; i += 1;
} }
} }