Skip to content

Maybe unsound in add_ref #51

@lwz23

Description

@lwz23

hello, thank you for your contribution in this project, I am scanning the unsoundness problem in rust project.
I notice the following code:

pub fn add_ref(&self) -> std::os::raw::c_long {
        unsafe {
            let this = self as *const IObjectArray as *const *const std::os::raw::c_void;
            let ret = ((*self.vtable).add_ref)(this);
            let ret: std::os::raw::c_long = ret.into();

            ret
        }
    }

Considering that vtable is a pub field, I assume that users can directly manipulate this field, and that add_ref is a public function. This potential situation could result in self.vtable being a null pointer, and directly dereferencing it might trigger undefined behavior (UB). For safety reasons, I felt it necessary to report this issue. If you have performed checks elsewhere that ensure this is safe, please don’t take offense at my raising this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions