core: fix read_XX_{be,le} funcs
authorKostya Shishkov <kostya.shishkov@gmail.com>
Sat, 17 Aug 2019 12:48:40 +0000 (14:48 +0200)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Sat, 17 Aug 2019 12:48:40 +0000 (14:48 +0200)
nihav-core/src/io/byteio.rs

index 545bff5c99ef6dee2754a87186cbff7962a8814d..e7e63dbd428f179e92aecfddc2f880d16c6cf2ac 100644 (file)
@@ -72,7 +72,7 @@ macro_rules! read_int_func {
             if src.len() < $size { return Err(ByteIOError::ReadError); }
             unsafe {
                 let mut buf: $inttype = 0;
-                ptr::copy_nonoverlapping(src.as_ptr(), &mut buf as *mut $inttype as *mut u8, 1);
+                ptr::copy_nonoverlapping(src.as_ptr(), &mut buf as *mut $inttype as *mut u8, std::mem::size_of::<$inttype>());
                 Ok(buf.$which())
             }
         }