diff options
Diffstat (limited to 'library/std/src/path/tests.rs')
| -rw-r--r-- | library/std/src/path/tests.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/library/std/src/path/tests.rs b/library/std/src/path/tests.rs index d29f895ba38..92702b395df 100644 --- a/library/std/src/path/tests.rs +++ b/library/std/src/path/tests.rs @@ -128,9 +128,12 @@ fn into() { #[test] fn test_pathbuf_leak() { - let buf = PathBuf::from("/have/a/cake".to_owned()); + let string = "/have/a/cake".to_owned(); + let (len, cap) = (string.len(), string.capacity()); + let buf = PathBuf::from(string); let leaked = buf.leak(); assert_eq!(leaked.as_os_str().as_encoded_bytes(), b"/have/a/cake"); + unsafe { drop(String::from_raw_parts(leaked.as_mut_os_str() as *mut OsStr as _, len, cap)) } } #[test] |
