Code Room
Code reviewHardcr-g160
Subject Use after freeLevel Senior–Staff~30 minCommon in Code quality & review interviewsIndustries Software development

Question

Review this Rust FFI-style helper using raw pointers.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix — specific and kind.

Talk through your review
Code to reviewrust
fn make_label() -> *const u8 {    let s = String::from("ready");    s.as_ptr()} fn main() {    let p = make_label();    unsafe {        let slice = std::slice::from_raw_parts(p, 5);        println!("{:?}", std::str::from_utf8_unchecked(slice));    }}
Run or narrate your approach, then ask the coach.