Skip to content

Commit

Permalink
Fix two instances of non-null-terminated strings in FFI calls
Browse files Browse the repository at this point in the history
Regression introduced by commit a2eb883.

Reported-by: Christian Hopps <chopps@labn.net>
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
  • Loading branch information
rwestphal committed Oct 23, 2024
1 parent aafda53 commit b6e8c6b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -496,11 +496,12 @@ impl<'a> DataTree<'a> {
) -> Result<DataTree<'a>> {
let mut rnode = std::ptr::null_mut();
let rnode_ptr = &mut rnode;
let cdata = CString::new(data.as_ref()).unwrap();

let ret = unsafe {
ffi::lyd_parse_data_mem(
context.raw,
data.as_ref().as_ptr() as _,
cdata.as_ptr() as _,
format as u32,
parser_options.bits(),
validation_options.bits(),
Expand All @@ -525,10 +526,10 @@ impl<'a> DataTree<'a> {
let rnode_ptr = &mut rnode;

// Create input handler.
let cdata = CString::new(data.as_ref()).unwrap();
let mut ly_in = std::ptr::null_mut();
let ret = unsafe {
ffi::ly_in_new_memory(data.as_ref().as_ptr() as _, &mut ly_in)
};
let ret =
unsafe { ffi::ly_in_new_memory(cdata.as_ptr() as _, &mut ly_in) };
if ret != ffi::LY_ERR::LY_SUCCESS {
return Err(Error::new(context));
}
Expand Down

0 comments on commit b6e8c6b

Please sign in to comment.