Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
imbillow committed May 31, 2024
1 parent 88edc83 commit b8b7d8c
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 40 deletions.
5 changes: 3 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ harness = false

[dependencies]
anyhow = "1.0.86"
libc = "0.2.155"
3 changes: 2 additions & 1 deletion examples/il-test.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use rizin_rs::wrapper::Core;
use anyhow::Result;

fn main() -> Result<(), ()> {
fn main() -> Result<()> {
let core = Core::new();
core.set("analysis.arch", "pic")?;
core.set("analysis.cpu", "pic18")?;
Expand Down
53 changes: 26 additions & 27 deletions fuzz/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,4 @@ mod tests {
}
}
}

#[test]
fn test_none() {
assert!(true);
}
}
16 changes: 11 additions & 5 deletions src/wrapper.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
use anyhow::anyhow;
use std::ffi::{CStr, CString};
use std::fmt::Display;
use std::marker::PhantomData;
use std::mem::ManuallyDrop;
use std::mem::{ManuallyDrop, size_of};
use std::ops::{Deref, DerefMut};
use std::path::PathBuf;
use std::ptr::{addr_of, addr_of_mut, null_mut, NonNull};
use std::{fmt, result, slice};

use anyhow::anyhow;

use crate::*;

pub type Result<T> = anyhow::Result<T>;
Expand Down Expand Up @@ -173,8 +174,12 @@ pub struct DwarfAbbrev(pub NonNull<RzBinDwarfAbbrev>);

impl DwarfAbbrev {
pub fn new(input: &[u8]) -> Result<DwarfAbbrev> {
let mut R = RzBinEndianReader::new(input, false);
let abbrev = unsafe { rz_bin_dwarf_abbrev_new(addr_of_mut!(R)) };
let R = RzBinEndianReader::new(input, false);
let abbrev = unsafe {
let ptr = libc::malloc(size_of::<RzBinEndianReader>());
libc::memcpy(ptr, addr_of!(R) as _, size_of::<RzBinEndianReader>());
rz_bin_dwarf_abbrev_new(ptr as _)
};
NonNull::<RzBinDwarfAbbrev>::new(abbrev)
.map(DwarfAbbrev)
.ok_or(anyhow!("failed new"))
Expand Down Expand Up @@ -378,9 +383,10 @@ impl<T> DerefMut for PVector<T> {

#[cfg(test)]
mod tests {
use crate::wrapper::*;
use std::mem::size_of;

use crate::wrapper::*;

#[test]
fn test_core() {
let _ = Core::new();
Expand Down

0 comments on commit b8b7d8c

Please sign in to comment.