std: fix aliasing bug in UNIX process implementation by joboet · Pull Request #138896 · rust-lang/rust (original) (raw)
CStringArray
contained both CString
s and their pointers. Unfortunately, since CString
uses Box
, moving the CString
s into the Vec
can (under stacked borrows) invalidate the pointer to the string, meaning the resulting Vec<*const c_char>
was, from an opsem perspective, unusable. This PR removes removes the Vec<CString>
from CStringArray
, instead recreating the CString
/CStr
from the pointers when necessary. Also,CStringArray
is now used for the process args as well, the old implementation was suffering from the same kind of bug.