Skip to content

Commit

Permalink
Start to work on sanitizers
Browse files Browse the repository at this point in the history
CXXFLAGS="-fsanitize=address -g" RUSTFLAGS=-Zsanitizer=address RUSTDOCFLAGS=-Zsanitizer=address cargo +nightly test --features bundled -Zbuild-std --target x86_64-unknown-linux-gnu -- --nocapture
  • Loading branch information
henkkuli committed Nov 14, 2023
1 parent 991fa87 commit 3c51c3f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@ bundled = []

[package.metadata.docs.rs]
features = ["bundled"]

[profile.test]
opt-level = 1

9 changes: 8 additions & 1 deletion src/font_face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl<'a> FontFace<'a> {
/// let font = FontFace::new(Blob::from_file("tests/fonts/NotoSans.ttf")?)?;
/// let processed = font.preprocess_for_subsetting();
/// for subset in subsets() {
/// subset.subset_font(&processed)?;
/// //subset.subset_font(&processed)?;
/// }
/// # Ok(())
/// # }
Expand Down Expand Up @@ -559,6 +559,13 @@ impl<'a> Deref for PreprocessedFontFace<'a> {
}
}

impl<'a> Drop for PreprocessedFontFace<'a> {
#[doc(alias = "hb_face_destroy")]
fn drop(&mut self) {
unsafe { sys::hb_face_destroy(self.0) }
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
10 changes: 6 additions & 4 deletions src/subset.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::marker::PhantomData;
use std::{marker::PhantomData, ptr::null_mut};

use crate::{sys, AllocationError, CharSet, FontFace, Map, Set, SubsettingError, TagSet, U32Set};

Expand Down Expand Up @@ -305,9 +305,9 @@ impl<'f, 'b> SubsetPlan<'f, 'b> {
/// This method transfers the ownership of the subset plan to the caller. It is up to the caller to call
/// [`sys::hb_subset_plan_destroy`] to free the pointer, or call [`Self::from_raw`] to convert it back into
/// [`SubsetPlan`].
pub fn into_raw(self) -> *mut sys::hb_subset_plan_t {
pub fn into_raw(mut self) -> *mut sys::hb_subset_plan_t {
let ptr = self.plan;
std::mem::forget(self);
self.plan = null_mut();
ptr
}

Expand Down Expand Up @@ -353,7 +353,9 @@ impl<'f, 'b> SubsetPlan<'f, 'b> {
impl<'f, 'b> Drop for SubsetPlan<'f, 'b> {
#[doc(alias = "hb_subset_plan_destroy")]
fn drop(&mut self) {
unsafe { sys::hb_subset_plan_destroy(self.plan) }
if !self.plan.is_null() {
unsafe { sys::hb_subset_plan_destroy(self.plan) }
}
}
}

Expand Down

0 comments on commit 3c51c3f

Please sign in to comment.