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

Null pointer causing crash in debug builds. #24

Open
Makogan opened this issue Mar 5, 2024 · 1 comment
Open

Null pointer causing crash in debug builds. #24

Makogan opened this issue Mar 5, 2024 · 1 comment

Comments

@Makogan
Copy link

Makogan commented Mar 5, 2024

I suspect there is a bug in the library. In particular at line:

let ffi_members =

It seems like it is possible for ffi_type.members to be null if ffi_type.member_count is 0. However, rust considers this unsafe and will return the error:

unsafe precondition(s) violated: slice::from_raw_parts requires the pointer to be aligned and non-null, and the total size of the slice not to exceed `isize::MAX`

Thus no application using this crate can run correctly in debug mode.

OS: ubuntu 22.04
crate version: 0.2.3
rustc version: rustc 1.78.0-nightly (ef324565d 2024-02-27)

@Makogan
Copy link
Author

Makogan commented Mar 5, 2024

I pushed a PR that addresses the issue. It's just a matter of explicitly checking for null pointers. In the process I also noticed that the rust crate points to a rather old commit of the C repo.

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