Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnsafeDestructor False Negative #58

Open
stoneman258 opened this issue Sep 24, 2024 · 0 comments
Open

UnsafeDestructor False Negative #58

stoneman258 opened this issue Sep 24, 2024 · 0 comments

Comments

@stoneman258
Copy link

Description:

I encountered an issue while testing with a slightly modified version of the test case from Rudra/tests/unsafe_destructor/normal2.rs. The issue is that Rudra does not report the UnsafeDestructor warning, even though it should.

Case

use std::ffi::CString;
use std::os::raw::c_char;

pub struct StrcCtx {
    pub ptr: *mut c_char,
}

impl Drop for StrcCtx {
    fn drop(&mut self) {
        let _ = self.to_cstring();
    }
}

impl StrcCtx {
    fn to_cstring(&mut self) -> CString {
        unsafe { std::ffi::CString::from_raw(self.ptr as *mut std::os::raw::c_char) }
    }
}

Expected Behavior:

Rudra should report an UnsafeDestructor warning for the modified test case.

Actual Behavior:

Rudra does not report any UnsafeDestructor warning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant