md_enter_child_containers: Fix crash (issue #10). Calling md_push_container_bytes() may result in ending a current block which may result in removing some contents from ctx->block_bytes when removing some lines with link reference definitions. This in effect means we have to end the block explicitly before storing the offset into the ctx->block_bytes.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
diff --git a/md4c/md4c.c b/md4c/md4c.c
index 116a92f..fcb88a8 100644
--- a/md4c/md4c.c
+++ b/md4c/md4c.c
@@ -4678,7 +4678,9 @@ md_enter_child_containers(MD_CTX* ctx, int n_children)
case _T('*'):
/* Remember offset in ctx->block_bytes so we can revisit the
* block if we detect it is a loose list. */
+ md_end_current_block(ctx);
c->block_byte_off = ctx->n_block_bytes;
+
MD_CHECK(md_push_container_bytes(ctx,
(is_ordered_list ? MD_BLOCK_OL : MD_BLOCK_UL),
c->start, MD_BLOCK_CONTAINER_OPENER));
diff --git a/test/coverage.txt b/test/coverage.txt
index e092048..8a05e51 100644
--- a/test/coverage.txt
+++ b/test/coverage.txt
@@ -63,3 +63,18 @@ att2=tok2> bar</p>
bar</a></p>
</blockquote>
````````````````````````````````
+
+### [Issue 10](https://github.com/mity/md4c/issues/10)
+```````````````````````````````` example
+[x]:
+x
+- <?
+
+ x
+.
+<ul>
+<li><?
+<p>x</p>
+</li>
+</ul>
+````````````````````````````````