Skip to content

Ch 2. example error #9

@orpheezt

Description

@orpheezt

Rust 1.92.0

  • no_mangle requires unsafe
  • And
let output = unsafe { core::slice::from_raw_parts_mut(0 as *mut u8, new_len) };
error: calling this function with a null pointer is undefined behavior, even if the result of the function is unused
  --> src/lib.rs:10:27
   |
10 |     let output = unsafe { core::slice::from_raw_parts_mut(0 as *mut u8, new_sz) };
   |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-^^^^^^^^^^^^^^^^^^^^
   |                                                           |
   |                                                           null pointer originates from here
   |
   = help: for more information, visit <https://doc.rust-lang.org/std/ptr/index.html> and <https://doc.rust-lang.org/reference/behavior-considered-undefined.html>
   = note: `#[deny(invalid_null_arguments)]` on by default

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