diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs index 77b90c0846b..6f217be31fe 100644 --- a/src/libstd/ffi/c_str.rs +++ b/src/libstd/ffi/c_str.rs @@ -213,6 +213,7 @@ impl CString { /// byte vector, not anything that can be converted to one with Into. #[stable(feature = "rust1", since = "1.0.0")] pub unsafe fn from_vec_unchecked(mut v: Vec) -> CString { + v.reserve_exact(1); v.push(0); CString { inner: v.into_boxed_slice() } }