Skip to content

Commit

Permalink
Remove unsafe code
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanUkhov committed Feb 16, 2024
1 parent 6f09d70 commit d8b6307
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "postscript"
version = "0.18.1"
version = "0.18.2"
edition = "2021"
license = "Apache-2.0/MIT"
authors = ["Ivan Ukhov <ivan.ukhov@gmail.com>"]
Expand All @@ -14,7 +14,7 @@ keywords = ["font", "postscript", "typeface", "typography"]
exclude = ["tests/fixtures/*"]

[dependencies]
typeface = "0.4.0"
typeface = "0.4.2"

[dev-dependencies]
random = "0.12"
8 changes: 2 additions & 6 deletions src/compact1/offset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,12 @@ impl crate::walue::Read<'static> for Offset {
type Parameter = OffsetSize;

fn read<T: crate::tape::Read>(tape: &mut T, size: OffsetSize) -> Result<Self> {
#[cfg(target_endian = "big")]
macro_rules! assemble(($hi:expr, $me:expr, $lo:expr) => ([0, $hi, $me, $lo]));
#[cfg(target_endian = "little")]
macro_rules! assemble(($hi:expr, $me:expr, $lo:expr) => ([$lo, $me, $hi, 0]));
Ok(Offset(match size {
1 => tape.take::<u8>()? as u32,
2 => tape.take::<u16>()? as u32,
3 => {
let trio: [u8; 3] = tape.take()?;
unsafe { std::mem::transmute::<_, u32>(assemble!(trio[0], trio[1], trio[2])) }
let value: [u8; 3] = tape.take()?;
u32::from_be_bytes([0, value[0], value[1], value[2]])
}
4 => tape.take::<u32>()?,
_ => raise!("found a malformed offset"),
Expand Down

0 comments on commit d8b6307

Please sign in to comment.