File tree Expand file tree Collapse file tree 3 files changed +21
-5
lines changed Expand file tree Collapse file tree 3 files changed +21
-5
lines changed Original file line number Diff line number Diff line change 2
2
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
3
3
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4
4
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5
- refs/heads/try: 59abf93b799a588e07060c7e4efd5f20cdce4293
5
+ refs/heads/try: 10236f8cd48ad862c32573411acb4423e441f883
6
6
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
Original file line number Diff line number Diff line change @@ -1509,10 +1509,8 @@ let i = str::as_bytes(\"Hello World\") { |bytes| vec::len(bytes) };
1509
1509
~~~
1510
1510
" ]
1511
1511
fn as_bytes < T > ( s : str , f : fn ( [ u8 ] ) -> T ) -> T unsafe {
1512
- let mut v: [ u8 ] = :: unsafe:: reinterpret_cast ( s) ;
1513
- let r = f ( v) ;
1514
- :: unsafe:: forget ( v) ;
1515
- r
1512
+ let v: * [ u8 ] = :: unsafe:: reinterpret_cast ( ptr:: addr_of ( s) ) ;
1513
+ f ( * v)
1516
1514
}
1517
1515
1518
1516
#[ doc = "
@@ -2449,6 +2447,14 @@ mod tests {
2449
2447
assert ( c == "AAA" ) ;
2450
2448
}
2451
2449
2450
+ #[ test]
2451
+ #[ ignore( cfg( target_os = "win32" ) ) ]
2452
+ #[ should_fail]
2453
+ fn test_as_bytes_fail ( ) {
2454
+ // Don't double free
2455
+ as_bytes ( "" ) { |_bytes| fail }
2456
+ }
2457
+
2452
2458
#[ test]
2453
2459
fn test_as_buf ( ) unsafe {
2454
2460
let a = "Abcdefg" ;
Original file line number Diff line number Diff line change
1
+ // error-pattern:explicit failure
2
+ // Don't double free the string
3
+ use std;
4
+ import io:: { reader, reader_util} ;
5
+
6
+ fn main ( ) {
7
+ io:: with_str_reader ( "" ) { |rdr|
8
+ alt rdr. read_char ( ) { '=' { } _ { fail } }
9
+ }
10
+ }
You can’t perform that action at this time.
0 commit comments