libfmod icon indicating copy to clipboard operation
libfmod copied to clipboard

CString dangling pointer UB in generator

Open utgarda opened this issue 3 months ago • 0 comments

Generator creates UB: CString temporary dropped before FFI reads pointer. Location: libfmod-gen/src/generators/lib.rs lines 483, 547

// Generated (WRONG):
CString::new(path)?.as_ptr()  // CString drops, pointer dangles

Impact: 35 functions (all string parameters)

Fix

// Bind before use:
let c_path = CString::new(path)?;
ffi_call(c_path.as_ptr())

Generator change: Add target field to InArgument struct

utgarda avatar Oct 30 '25 15:10 utgarda