Skip to content

Commit 87abe17

Browse files
committed
Added a warning to CString::into_raw too
1 parent 00a7b56 commit 87abe17

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/libstd/ffi/c_str.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,11 @@ impl CString {
446446
///
447447
/// Failure to call [`from_raw`] will lead to a memory leak.
448448
///
449+
/// The C side must **not** modify the length of the string (by writing a
450+
/// `NULL` somewhere inside the string or removing the final one) before
451+
/// it makes it back into Rust using [`from_raw`]. See the safety section
452+
/// in [`from_raw`].
453+
///
449454
/// [`from_raw`]: #method.from_raw
450455
///
451456
/// # Examples

0 commit comments

Comments
 (0)