Commit 5710bfec81e388e02ebbc601b66888db436bc9bc

Martin Mitas 2018-06-11T14:13:28

Fix/simplify handling of end-of-file special mark. Fixes #43.

diff --git a/md4c/md4c.c b/md4c/md4c.c
index 0efa34f..50ff1c5 100644
--- a/md4c/md4c.c
+++ b/md4c/md4c.c
@@ -3026,9 +3026,9 @@ md_collect_marks(MD_CTX* ctx, const MD_LINE* lines, int n_lines, int table_mode)
         }
     }
 
-    /* Add a dummy mark after the end of processed block to simplify
-     * md_process_inlines(). */
-    PUSH_MARK(127, ctx->size+1, ctx->size+1, MD_MARK_RESOLVED);
+    /* Add a dummy mark at the end of the mark vector to simplify
+     * process_inlines(). */
+    PUSH_MARK(127, ctx->size, ctx->size, MD_MARK_RESOLVED);
 
 abort:
     return ret;
@@ -4012,6 +4012,9 @@ md_process_inlines(MD_CTX* ctx, const MD_LINE* lines, int n_lines)
                 case '\0':
                     MD_TEXT(MD_TEXT_NULLCHAR, _T(""), 1);
                     break;
+
+                case 127:
+                    goto abort;
             }
 
             off = mark->end;