avoid panic if someone cats a PNG to the terminal

This commit is contained in:
Wez Furlong committed 2020-10-16 13:09:50 -07:00
1 parent 4a43c30c9a
commit 0ec79a40f6
2 files changed
+3 -2

No files matched your search

+2 -1
View File
@@ -261,7 +261,8 @@ impl OperatingSystemCommand {
// So, for non-numeric OSCs, we look up the prefix and use that.
// This only works if the non-numeric OSC code has length == 1.
let osc_code = if !p1str.chars().nth(0).unwrap().is_ascii_digit() && osc.len() == 1 {
OperatingSystemCommandCode::from_code(&p1str[0..1])
let p1rest: String = p1str.chars().skip(1).collect();
OperatingSystemCommandCode::from_code(&p1rest)
} else {
OperatingSystemCommandCode::from_code(&p1str)
}
+1 -1
View File
@@ -307,7 +307,7 @@ impl OscState {
self.full = true;
}
num => {
self.param_indices[num - 1] = self.buffer.len();
self.param_indices[num.saturating_sub(1)] = self.buffer.len();
self.num_params += 1;
}
}