Skip to content

Commit 85d2eb9

Browse files
committed
Expose CMARK_NODE_FOOTNOTE_DEFINION literal value.
In addition, fix a bug where the length of the literal value was calculated AFTER the actual literal string (null terminated) was allocated.
1 parent 2d65cd3 commit 85d2eb9

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/blocks.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1220,12 +1220,13 @@ static void open_new_blocks(cmark_parser *parser, cmark_node **container,
12201220
parser->options & CMARK_OPT_FOOTNOTES &&
12211221
(matched = scan_footnote_definition(input, parser->first_nonspace))) {
12221222
cmark_chunk c = cmark_chunk_dup(input, parser->first_nonspace + 2, matched - 2);
1223-
cmark_chunk_to_cstr(parser->mem, &c);
12241223

12251224
while (c.data[c.len - 1] != ']')
12261225
--c.len;
12271226
--c.len;
12281227

1228+
cmark_chunk_to_cstr(parser->mem, &c);
1229+
12291230
S_advance_offset(parser, input, parser->first_nonspace + matched - parser->offset, false);
12301231
*container = add_child(parser, *container, CMARK_NODE_FOOTNOTE_DEFINITION, parser->first_nonspace + matched + 1);
12311232
(*container)->as.literal = c;

src/node.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ const char *cmark_node_get_literal(cmark_node *node) {
377377
case CMARK_NODE_HTML_INLINE:
378378
case CMARK_NODE_CODE:
379379
case CMARK_NODE_FOOTNOTE_REFERENCE:
380+
case CMARK_NODE_FOOTNOTE_DEFINITION:
380381
return cmark_chunk_to_cstr(NODE_MEM(node), &node->as.literal);
381382

382383
case CMARK_NODE_CODE_BLOCK:

0 commit comments

Comments
 (0)