Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segfault during glyph outlining #219

Open
RazrFalcon opened this issue Jun 4, 2019 · 1 comment
Open

Segfault during glyph outlining #219

RazrFalcon opened this issue Jun 4, 2019 · 1 comment

Comments

@RazrFalcon
Copy link

The glyph_outline example crashes with segfault while trying to outline the 0 glyph (I had to modify the example a bit, since it accepts only characters) using the Noto Tinos-BoldItalic.ttf (md5sum d303824b18cfd6f13838f94791b708bd).

Output:
terminated by signal SIGSEGV (Address boundary error)

According to gdb it crashes here.

freetype-rs 0.20.0

@johnoneil
Copy link

Yeah I'm seeing this as well.
The origin of the issue (at least for me) seems to be in attempting to get an outline for a glyph with no geometry (say for example a space).
This case can be reproduced via the glyph_outline example without changes via:

cargo run --example glyph_outline examples/assets/FiraSans-Regular.ttf ' '

Here I'm passing a space as the outlined character (unicode codepoint 0x20 or 32 decimal).

I've caught this in the debugger and it appears a null ptr check is needed in the following code in outline.rs

impl<'a> Iterator for ContourIterator<'a> {
    type Item = CurveIterator<'a>;

    fn next(&mut self) -> Option<Self::Item> {
        if self.contour_end_idx > self.last_end_idx {
            None
        } else {
            unsafe {
                let contour_end = *self.contour_end_idx; // <-- dereferncing a null ptr here !!!
                let curves = CurveIterator::from_raw(self.outline, self.contour_start as isize,
                                                     contour_end as isize);
                self.contour_start = contour_end + 1;
                self.contour_end_idx = self.contour_end_idx.offset(1);

                Some(curves)
            }
        }
    }
}

I could provide a PR for this as it would improve out client which is using this crate, but as you know the binding better I'll accept how you want to proceed on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants