Skip to content

Commit cfcb18a

Browse files
committed
Add dangling safety in CString::from_raw
1 parent cdc4c8d commit cfcb18a

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

library/alloc/src/ffi/c_str.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ impl CString {
359359
///
360360
/// This function does not validate ownership of the raw pointer's memory.
361361
/// A double-free may occur if the function is called twice on the same raw pointer.
362+
/// Additionally, the caller must ensure the pointer is not dangling.
362363
///
363364
/// It should be noted that the length isn't just "recomputed," but that
364365
/// the recomputed length must match the original length from the

0 commit comments

Comments
 (0)