Commit 76abc636ad7a9d176f8ec9255cc6ea3edaba9bf9

Martin Mitas 2024-01-11T12:09:22

md_is_html_block_end_condition: Fix EOF handling.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
diff --git a/src/md4c.c b/src/md4c.c
index 304733c..0d384ad 100644
--- a/src/md4c.c
+++ b/src/md4c.c
@@ -5538,8 +5538,12 @@ md_is_html_block_end_condition(MD_CTX* ctx, OFF beg, OFF* p_end)
 
         case 6:     /* Pass through */
         case 7:
-            *p_end = beg;
-            return (ISNEWLINE(beg) ? ctx->html_block_type : FALSE);
+            if(beg >= ctx->size  ||  ISNEWLINE(beg)) {
+                /* Blank line ends types 6 and 7. */
+                *p_end = beg;
+                return TRUE;
+            }
+            return FALSE;
 
         default:
             MD_UNREACHABLE();