about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorAlexis Bourget <alexis.bourget@gmail.com>2020-06-03 23:55:41 +0200
committerAlexis Bourget <alexis.bourget@gmail.com>2020-06-03 23:55:41 +0200
commit87abe174c46bf10246369e63a36eccd6748b7dbe (patch)
treeef41b0775579f422b3d71b39adfea5f1547d5623 /src/libstd
parent00a7b56bab317d9f1aaa5255145ce3414081cbfe (diff)
downloadrust-87abe174c46bf10246369e63a36eccd6748b7dbe.tar.gz
rust-87abe174c46bf10246369e63a36eccd6748b7dbe.zip
Added a warning to CString::into_raw too
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/ffi/c_str.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs
index 3d7ac724fbd..b324b161896 100644
--- a/src/libstd/ffi/c_str.rs
+++ b/src/libstd/ffi/c_str.rs
@@ -446,6 +446,11 @@ impl CString {
     ///
     /// Failure to call [`from_raw`] will lead to a memory leak.
     ///
+    /// The C side must **not** modify the length of the string (by writing a
+    /// `NULL` somewhere inside the string or removing the final one) before
+    /// it makes it back into Rust using [`from_raw`]. See the safety section
+    /// in [`from_raw`].
+    ///
     /// [`from_raw`]: #method.from_raw
     ///
     /// # Examples