Skip to content

CString dangling pointer UB in generator #24

@utgarda

Description

@utgarda

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

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