We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fe0e2ae commit 0c1dcb0Copy full SHA for 0c1dcb0
src/metadata.rs
@@ -1,3 +1,4 @@
1
+use std::convert::TryFrom;
2
use std::fs::File;
3
use std::path::Path;
4
@@ -24,7 +25,10 @@ impl MetadataLoader for CraneliftMetadataLoader {
24
25
while let Some(entry_result) = archive.next_entry() {
26
let mut entry = entry_result.map_err(|e| format!("{:?}", e))?;
27
if entry.header().identifier() == METADATA_FILENAME.as_bytes() {
- 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
+ );
32
::std::io::copy(&mut entry, &mut buf).map_err(|e| format!("{:?}", e))?;
33
let buf: OwningRef<Vec<u8>, [u8]> = OwningRef::new(buf).into();
34
return Ok(rustc_erase_owner!(buf.map_owner_box()));
0 commit comments