Skip to content

pulldown-cmark panics on first pass when enabling definition-lists #973

@ytmimi

Description

@ytmimi

I'm not sure if nested definition lists are valid, but using pulldown-cmark 0.12.2 and the following input causes a panic:

level one!
:
    level two!
    :
        level three!
        :

new level one!
:

Here's a small program that reproduces the issue:

use pulldown_cmark::{Options, Parser};

static INPUT: &str = "
level one!
:
    level two!
    :
        level three!
        :

new level one!
:
";

fn main() {
    let options = Options::ENABLE_DEFINITION_LIST;
    let parser = Parser::new_ext(INPUT, options);
    for _ in parser {}
}
Traceback
thread 'main' panicked at /Users/ytmimi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pulldown-cmark-0.12.2/src/firstpass.rs:1540:38:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0: rust_begin_unwind
             at /rustc/e7c0d2750726c1f08b1de6956248ec78c4a97af6/library/std/src/panicking.rs:665:5
   1: core::panicking::panic_fmt
             at /rustc/e7c0d2750726c1f08b1de6956248ec78c4a97af6/library/core/src/panicking.rs:74:14
   2: core::panicking::panic
             at /rustc/e7c0d2750726c1f08b1de6956248ec78c4a97af6/library/core/src/panicking.rs:148:5
   3: core::option::unwrap_failed
             at /rustc/e7c0d2750726c1f08b1de6956248ec78c4a97af6/library/core/src/option.rs:2012:5
   4: core::option::Option<T>::unwrap
             at /Users/ytmimi/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/option.rs:972:21
   5: pulldown_cmark::firstpass::FirstPass::pop
             at /Users/ytmimi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pulldown-cmark-0.12.2/src/firstpass.rs:1540:22
   6: pulldown_cmark::firstpass::FirstPass::parse_block
             at /Users/ytmimi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pulldown-cmark-0.12.2/src/firstpass.rs:99:13
   7: pulldown_cmark::firstpass::FirstPass::run
             at /Users/ytmimi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pulldown-cmark-0.12.2/src/firstpass.rs:76:18
   8: pulldown_cmark::firstpass::run_first_pass
             at /Users/ytmimi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pulldown-cmark-0.12.2/src/firstpass.rs:41:5
   9: pulldown_cmark::parse::Parser<F>::new_with_broken_link_callback
             at /Users/ytmimi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pulldown-cmark-0.12.2/src/parse.rs:270:34
  10: pulldown_cmark::parse::Parser::new_ext
             at /Users/ytmimi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pulldown-cmark-0.12.2/src/parse.rs:255:9
  11: example::main
             at ./src/example.rs:19:18
  12: core::ops::function::FnOnce::call_once
             at /Users/ytmimi/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions