File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change
1
+ use std:: convert:: TryFrom ;
1
2
use std:: fs:: File ;
2
3
use std:: path:: Path ;
3
4
@@ -24,7 +25,10 @@ impl MetadataLoader for CraneliftMetadataLoader {
24
25
while let Some ( entry_result) = archive. next_entry ( ) {
25
26
let mut entry = entry_result. map_err ( |e| format ! ( "{:?}" , e) ) ?;
26
27
if entry. header ( ) . identifier ( ) == METADATA_FILENAME . as_bytes ( ) {
27
- let mut buf = Vec :: new ( ) ;
28
+ let mut buf = Vec :: with_capacity (
29
+ usize:: try_from ( entry. header ( ) . size ( ) )
30
+ . expect ( "Rlib metadata file too big to load into memory." )
31
+ ) ;
28
32
:: std:: io:: copy ( & mut entry, & mut buf) . map_err ( |e| format ! ( "{:?}" , e) ) ?;
29
33
let buf: OwningRef < Vec < u8 > , [ u8 ] > = OwningRef :: new ( buf) . into ( ) ;
30
34
return Ok ( rustc_erase_owner ! ( buf. map_owner_box( ) ) ) ;
You can’t perform that action at this time.
0 commit comments