File tree 1 file changed +7
-2
lines changed
1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -228,9 +228,14 @@ impl CString {
228
228
229
229
/// Retakes ownership of a `CString` that was transferred to C.
230
230
///
231
+ /// Additionally, the length of the string will be recalculated from the pointer.
232
+ ///
233
+ /// # Safety
234
+ ///
231
235
/// This should only ever be called with a pointer that was earlier
232
- /// obtained by calling `into_raw` on a `CString`. Additionally, the length
233
- /// of the string will be recalculated from the pointer.
236
+ /// obtained by calling `into_raw` on a `CString`. Other usage (e.g. trying to take
237
+ /// ownership of a string that was allocated by foreign code) is likely to lead
238
+ /// to undefined behavior or allocator corruption.
234
239
#[ stable( feature = "cstr_memory" , since = "1.4.0" ) ]
235
240
pub unsafe fn from_raw ( ptr : * mut c_char ) -> CString {
236
241
let len = libc:: strlen ( ptr) + 1 ; // Including the NUL byte
You can’t perform that action at this time.
0 commit comments