Skip to content

Warn against passing a pointer derived from a 0 or 1 sized array to from_raw_parts #5591

Open
@retep998

Description

@retep998

If there is a fixed size array with a length of 0 or 1, and as_ptr() or as_ptr_mut() is called on that array and the result passed to slice::from_raw_parts or slice::from_raw_parts_mut, then emit a lint.

This is almost definitely a sign of UB: rust-lang/unsafe-code-guidelines#134 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintArea: New lintsE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.L-correctnessLint: Belongs in the correctness lint group

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions