From 2bac4575c69ef7aba8da9e2f15af4c95644b3556 Mon Sep 17 00:00:00 2001 From: Yuki Izumi Date: Mon, 26 Sep 2016 16:20:54 +1000 Subject: Fix memory leak in list parsing If `parse_list_marker` returns 1, but the second part of the `&&` clause is false, we leak `data` here. --- src/blocks.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/blocks.c') diff --git a/src/blocks.c b/src/blocks.c index 8e8c4c2..a5f8eca 100644 --- a/src/blocks.c +++ b/src/blocks.c @@ -933,10 +933,10 @@ static void open_new_blocks(cmark_parser *parser, cmark_node **container, *container = add_child(parser, *container, CMARK_NODE_THEMATIC_BREAK, parser->first_nonspace + 1); S_advance_offset(parser, input, input->len - 1 - parser->offset, false); - } else if ((matched = parse_list_marker( + } else if ((!indented || cont_type == CMARK_NODE_LIST) && + (matched = parse_list_marker( parser->mem, input, parser->first_nonspace, - (*container)->type == CMARK_NODE_PARAGRAPH, &data)) && - (!indented || cont_type == CMARK_NODE_LIST)) { + (*container)->type == CMARK_NODE_PARAGRAPH, &data))) { // Note that we can have new list items starting with >= 4 // spaces indent, as long as the list container is still open. -- cgit v1.2.3