File tree Expand file tree Collapse file tree 2 files changed +6
-1
lines changed Expand file tree Collapse file tree 2 files changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -26,8 +26,10 @@ fn test_os_string_clear() {
2626#[ test]
2727fn test_os_string_leak ( ) {
2828 let os_string = OsString :: from ( "have a cake" ) ;
29+ let ( len, cap) = ( os_string. len ( ) , os_string. capacity ( ) ) ;
2930 let leaked = os_string. leak ( ) ;
3031 assert_eq ! ( leaked. as_encoded_bytes( ) , b"have a cake" ) ;
32+ unsafe { drop ( String :: from_raw_parts ( leaked as * mut OsStr as _ , len, cap) ) }
3133}
3234
3335#[ test]
Original file line number Diff line number Diff line change @@ -128,9 +128,12 @@ fn into() {
128128
129129#[ test]
130130fn test_pathbuf_leak ( ) {
131- let buf = PathBuf :: from ( "/have/a/cake" . to_owned ( ) ) ;
131+ let string = "/have/a/cake" . to_owned ( ) ;
132+ let ( len, cap) = ( string. len ( ) , string. capacity ( ) ) ;
133+ let buf = PathBuf :: from ( string) ;
132134 let leaked = buf. leak ( ) ;
133135 assert_eq ! ( leaked. as_os_str( ) . as_encoded_bytes( ) , b"/have/a/cake" ) ;
136+ unsafe { drop ( String :: from_raw_parts ( leaked. as_mut_os_str ( ) as * mut OsStr as _ , len, cap) ) }
134137}
135138
136139#[ test]
You can’t perform that action at this time.
0 commit comments