File tree 1 file changed +5
-2
lines changed
1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -225,8 +225,11 @@ impl CString {
225
225
/// Retakes ownership of a `CString` that was transferred to C.
226
226
///
227
227
/// This should only ever be called with a pointer that was earlier
228
- /// obtained by calling `into_raw` on a `CString`. Additionally, the length
229
- /// of the string will be recalculated from the pointer.
228
+ /// obtained by calling `into_raw` on a `CString`. In particular, using this method
229
+ /// to create a `CString` pointing at memory that will be freed by other code
230
+ /// (such as a C library) will lead to undefined behavior!
231
+ ///
232
+ /// Additionally, the length of the string will be recalculated from the pointer.
230
233
#[ stable( feature = "cstr_memory" , since = "1.4.0" ) ]
231
234
pub unsafe fn from_raw ( ptr : * mut c_char ) -> CString {
232
235
let len = libc:: strlen ( ptr) + 1 ; // Including the NUL byte
You can’t perform that action at this time.
0 commit comments