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

Panic at !self.is_empty() assertion in tables/cff/argstack.rs #80

Closed
5225225 opened this issue Nov 19, 2021 · 1 comment
Closed

Panic at !self.is_empty() assertion in tables/cff/argstack.rs #80

5225225 opened this issue Nov 19, 2021 · 1 comment

Comments

@5225225
Copy link

5225225 commented Nov 19, 2021

Reproduction

fn main() {
    let data = b"OTTO\x00\t\x00\x80\x00\x03\x00\x10CFF \xba\x8a\xb3\xe3\x00\x00\x03\
    \xf0\x00\x00\x00[OS/2T\xe9R\xb6\x00\x00\x01\x00\x00\x00\x00`cmap\x00{\x01\xa6\
    \x00\x00\x038\x00\x00\x00\x98head\xf0\xfal[\x00\x00\x00\x9c\x00\x00\x006hhea\x068\
    \x02M\x00\x00\x00\xd4\x00\x00\x00$hmtx\x07)\x00\x00\x00\x00\x04L\x00\x00\x00\x0cmaxp\
    \x00\x03P\x00\x00\x00\x00\xf8\x00\x00\x00\x06name\xf1+\xeb\xf6\x00\x00\x01`\x00\
    \x00\x01\xd7post\xff\xb8\x002\x00\x00\x03\xd0\x00\x00\x00 \x00\x01\x00\x00\x00\
    \x01\x00&\xe8xq\xb3_\x0f<\xf5\x00\x03\x03\xe8\x00\x00\x00\x00\xc7R\x94\x89\x00\
    \x00\x00\x00\xc7R\x94\x89\x00\x00\x00\xf3\x03?\x01v\x00\x00\x00\x03\x00\x02\x00\
    \x00\x00\x00\x00\x00\x00\x01\x00\x00\x02\xee\xff\x06\x00\t\x03A\x00\x00\x00\x02\
    \x03?\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\
    \x00\x00P\x00\x00\x03\x00\x00\x00\x02\x02c\x01\x90\x00\x05\x00\x00\x02\xbc\x02\
    \x8a\x00\x00\x00\x8c\x02\xbc\x02\x8a\x00\x00\x01\xdd\x002\x00\xfa\x00\x00\x00\
    \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\
    \x00\x00\x00\x00\x00FHD\x00\x00@\x00 \x00-\x02\xee\xff\x06\x00\x00\x02\xf5\x00\
    \xf3\x00\x00\x00\x01\x00\x00\x00\x00\x01\xf4\x02\xbc\x00\x00\x00 \x00\x00\x00\
    \x00\x00\x10\x00\xc6\x00\x01\x00\x00\x00\x00\x00\x00\x00<\x00\x00\x00\x00\t\x00\
    \x00\x00\x00\xf9\xff\xfd\xff\xc3\xff\xfe\xff\x00\x00\x00\x00\x02\x00\x07\x00>\
    \x00\x00\x01\x00\x00\x00\x00\x03\x00\x11\x00E\x00\x01\x00\x00\x00\x00\x00\x04\
    \x00\x02\x00<\x00\x01\x00\x00\x00\x00\x00\x05\x00\x05\x00V\x00\x01\x00\x00\x00\
    \x00\x00\x06\x00\x02\x00<\x00\x01\x00\x00\x00\x00\x00\x10\x00\x02\x00<\x00\x01\
    \x00\x00\x00\x00\x00\x11\x00\x07\x00>\x00\x03\x00\x01\x04\t\x00\x00\x00x\x00[\
    \x00\x03\x00\x01\x04\t\x00\x01\x00\x04\x00\xd3\x00\x03\x00\x01\x04\t\x00\x02\x00\
    \x0e\x00\xd7\x00\x03\x00\x01\x04\t\x00\x03\x00\"\x00\xe5\x00\x03\x00\x01\x04\t\
    \x00\x1d\x00\x04\x00\xd3\x00\x03\x00\x01\x04\t\x00\x05\x00\n\x01\x07\x00\x03\x00\
    \x01\x04\t\x00\x06\x00\x04\x00\xd3Generated in 2009 by FontLab Studio. Copyright info pending.PIRegularFONTLAB:OTFEXPORT1.000\
    \x00G\x00e\x00n\x00e\x00r\x00a\x00t\x00e\x00d\x00 \x00i\x00n\x00 \x002\x000\x000\
    \x009\x00 \x00b\x00y\x00 \x00F\x00o\x00n\x00t\x00L\x00a\x00b\x00 \x00S\x00t\x00u\
    \x00d\x00i\x00o\x00.\x00 \x00C\x00o\x00p\x00y\x00r\x00i\x00g\x00h\x00t\x00 \x00i\
    \x00n\x00f\x00o\x00 \x00p\x00e\x00n\x00d\x00i\x00n\x00g\x00.\x00P\x00I\x00R\x00e\
    \x00g\x00u\x00l\x00a\x00r\x00F\x00O\x00N\x00T\x00L\x00A\x00B\x00:\x00O\x00T\x00F\
    \x00E\x00X\x00P\x00O\x00R\x00T\x001\x00.\x000\x000\x000\x00\x00\x00\x00\x03\x00\
    \x00\x00\x03\x00\x00\x00p\x00\x01\x00\x00\x00\x00\x00\x1c\x00\x03\x00\x01\x00\
    \x00\x00p\x00\x06\x00T\x00\x00\x00\t\x00%\x00\x02\x00\x00\x00\x00\x00\x00\x00\
    \x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
    \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\
    \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
    \x00\x00\x00\x00\x01\x00\x04\x00(\x00\x00\x00\x06\x00\x04\x00\x01\x00\x02\x00 \
    \x00-\xff\xff\x00\x00\x00 \x00-\xff\xff\xff\xe2\xff\xd4\x00\x01\x00\x00\x00\x00\
    \x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\xff\xb5\x002\x00\x00\x00\x00\x00\x00\
    \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x04\x01\x00\x01\
    \x01\x01\x03PI\x00\x01\x01\x01\x1c\xf8\x10\x00\xf8\x1b\x02\xf8\x1b\x03\xf8\x18\
    \x04\x8b\xf7\x87\xf9\xbf\x05\xf8\x0f\xd3\n\xc4\x11\x8e\xe3\x12\x00\x01\x01\x01\
    \x03PI\x00\x00\x00\x00\x0e\x00\x01\x00\x03\x01\x04\x16\x01\x19\xf8\x88\xf0\x87\
    \xf7\x17\x01\xf7\x87\x04\xf9\xd3\xf7\x17\xed\xf0\x0e\xd3\xf8\x88\x0e\x8b\x8b\x00\
    \xf4\x06\x00\x01\x00\x03A\x00\x00\x01\xf4\x00\x00";

    let face = ttf_parser::Face::from_slice(data, 0).unwrap();
    let _ = face.outline_glyph(ttf_parser::GlyphId(0), &mut Builder);
}

struct Builder;

impl ttf_parser::OutlineBuilder for Builder {
    #[inline]
    fn move_to(&mut self, _: f32, _: f32) {}

    #[inline]
    fn line_to(&mut self, _: f32, _: f32) {}

    #[inline]
    fn quad_to(&mut self, _: f32, _: f32, _: f32, _: f32) {}

    #[inline]
    fn curve_to(&mut self, _: f32, _: f32, _: f32, _: f32, _: f32, _: f32) {}

    #[inline]
    fn close(&mut self) {}
}

Stack Trace

thread 'main' panicked at 'assertion failed: !self.is_empty()', /home/jess/src/ttf-parser/src/tables/cff/argstack.rs:38:9
stack backtrace:
   0: rust_begin_unwind
             at /rustc/891ca5f63c3b3cfe3939710a728671243e881ed6/library/std/src/panicking.rs:498:5
   1: core::panicking::panic_fmt
             at /rustc/891ca5f63c3b3cfe3939710a728671243e881ed6/library/core/src/panicking.rs:106:14
   2: core::panicking::panic
             at /rustc/891ca5f63c3b3cfe3939710a728671243e881ed6/library/core/src/panicking.rs:47:5
   3: ttf_parser::tables::cff::argstack::ArgumentsStack::pop
             at /home/jess/src/ttf-parser/src/tables/cff/argstack.rs:38:9
   4: ttf_parser::tables::cff::cff1::_parse_char_string
             at /home/jess/src/ttf-parser/src/tables/cff/cff1.rs:455:25
   5: ttf_parser::tables::cff::cff1::parse_char_string
             at /home/jess/src/ttf-parser/src/tables/cff/cff1.rs:319:5
   6: ttf_parser::tables::cff::cff1::Table::outline
             at /home/jess/src/ttf-parser/src/tables/cff/cff1.rs:810:9
   7: ttf_parser::Face::outline_glyph
             at /home/jess/src/ttf-parser/src/lib.rs:1495:20
   8: scratchz9RXxFh8B::main
             at ./main.rs:49:13
   9: core::ops::function::FnOnce::call_once
             at /rustc/891ca5f63c3b3cfe3939710a728671243e881ed6/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
@RazrFalcon
Copy link
Owner

Turns out there were two bugs in one. Thanks again!

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