File tree 1 file changed +3
-2
lines changed
1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ use flate2::read::DeflateDecoder;
27
27
use std:: io:: Read ;
28
28
use std:: ffi:: CString ;
29
29
use std:: path:: Path ;
30
+ use std:: ptr:: read_unaligned;
30
31
31
32
pub fn crate_type_allows_lto ( crate_type : config:: CrateType ) -> bool {
32
33
match crate_type {
@@ -223,13 +224,13 @@ fn is_versioned_bytecode_format(bc: &[u8]) -> bool {
223
224
fn extract_bytecode_format_version ( bc : & [ u8 ] ) -> u32 {
224
225
let pos = link:: RLIB_BYTECODE_OBJECT_VERSION_OFFSET ;
225
226
let byte_data = & bc[ pos..pos + 4 ] ;
226
- let data = unsafe { * ( byte_data. as_ptr ( ) as * const u32 ) } ;
227
+ let data = unsafe { read_unaligned ( byte_data. as_ptr ( ) as * const u32 ) } ;
227
228
u32:: from_le ( data)
228
229
}
229
230
230
231
fn extract_compressed_bytecode_size_v1 ( bc : & [ u8 ] ) -> u64 {
231
232
let pos = link:: RLIB_BYTECODE_OBJECT_V1_DATASIZE_OFFSET ;
232
233
let byte_data = & bc[ pos..pos + 8 ] ;
233
- let data = unsafe { * ( byte_data. as_ptr ( ) as * const u64 ) } ;
234
+ let data = unsafe { read_unaligned ( byte_data. as_ptr ( ) as * const u64 ) } ;
234
235
u64:: from_le ( data)
235
236
}
You can’t perform that action at this time.
0 commit comments