rizinorg/rz-pipe

Rust rz-pipe shouldn't panic

spacemeowx2 opened this issue · 2 comments

As a library, rz-pipe should not panic user's process.

All uses of unwrap and expect should be removed. Use error instead.

sout.read_exact(&mut w).unwrap();

rz-pipe/rust/src/rzpipe.rs

Lines 265 to 272 in 76e7b67

let mut rz = RzPipe::spawn(name, opt).unwrap();
loop {
let cmd: String = hrx.recv().unwrap();
if cmd == "q" {
break;
}
let res = rz.cmdj(&cmd).unwrap().to_string();
htx.send(res.clone()).unwrap();

rz-pipe/rust/src/rzpipe.rs

Lines 332 to 337 in 76e7b67

pub fn cmd(&mut self, cmd: &str) -> Result<String, String> {
self.write.write_all(cmd.as_bytes()).unwrap();
let mut res: Vec<u8> = Vec::new();
self.read.read_until(0u8, &mut res).unwrap();
process_result(res)
}

let res = reqwest::get(&url).unwrap();

Rz::new::<&str>(None).expect("Unable to spawn rizin or find an open rzpipe")

Pls review @XVilka / @spacemeowx2 and pardon my rust n00bness lel

@spacemeowx2 does this still happen?