Skip to content

Commit

Permalink
Add error message when volatility profile is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
jamcleod committed Jan 8, 2024
1 parent 50426f6 commit 79b65a3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions panda/plugins/cosi/volatility_profile/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,12 @@ pub struct VolatilityJson {
impl VolatilityJson {
pub fn from_compressed_file(filename: impl AsRef<Path>) -> VolatilityJson {
//pub fn from_compressed_file(filename: std::fs::File) -> VolatilityJson {
let mut f = BufReader::new(File::open(filename).unwrap());
//let mut f = BufReader::new(filename);
let file = File::open(filename).unwrap();
if file.metadata().unwrap().len() == 0 {
panic!("cosi volatility profile empty");
}

let mut f = BufReader::new(file);
let mut decomp = Vec::new();
lzma_rs::xz_decompress(&mut f, &mut decomp).unwrap();
let s = String::from_utf8_lossy(&decomp);
Expand Down

0 comments on commit 79b65a3

Please sign in to comment.