Closed
Description
The signature of CString::new
is CString::new(buf: *const i8, owns_buffer: bool)
. The problem with this is that if the new CString
does own the buffer it's going to free it. In which case buf
should be a *mut i8
not a *const i8
. However making buf: *mut i8
doesn't account for the case where the CString
doesn't own the buffer and the buffer is immutable.
To fix this CString::new
should be split into two functions:
unsafe fn CString::new(buf: *const i8) -> CString;
unsafe fn CString::new_owned(buf: *mut i8) -> CString;
Metadata
Metadata
Assignees
Labels
No labels