Code Room
Code reviewHardcr-g380
Subject Double freeLevel Senior–Staff~26 minCommon in Code quality & review interviewsIndustries Software development

Question

Review this Rust FFI shim that hands a boxed handle to C and reclaims it.

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
#[no_mangle]pub extern "C" fn handle_new() -> *mut Conn {    Box::into_raw(Box::new(Conn::open()))} #[no_mangle]pub extern "C" fn handle_free(p: *mut Conn) {    if p.is_null() { return; }    unsafe {        let _ = Box::from_raw(p);   // reconstruct & drop        drop(Box::from_raw(p));     // ensure dropped    }}
Run or narrate your approach, then ask the coach.