Skip to content

Commit

Permalink
Oops two lines of unsafe code and I do a double free
Browse files Browse the repository at this point in the history
  • Loading branch information
bcpeinhardt authored and dginev committed Mar 26, 2022
1 parent 6617a19 commit 84e7b08
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/xpath.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ pub fn xml_xpath_compiles(xpath: &str) -> bool {
let c_xpath = CString::new(xpath).unwrap();
let xml_xpath_comp_expr_ptr = unsafe { xmlXPathCompile(c_xpath.as_bytes().as_ptr()) };
let result = !xml_xpath_comp_expr_ptr.is_null();
unsafe { libc::free(xml_xpath_comp_expr_ptr as *mut c_void); }
if result {
unsafe { libc::free(xml_xpath_comp_expr_ptr as *mut c_void); }
}
result
}

0 comments on commit 84e7b08

Please sign in to comment.