Commit 006611b9ab480e5207d753d68310e1f069ced1a6

Martin Mitas 2024-01-17T15:03:00

md_analyze_dollar: Call md_rollback() only when resolving. Fixes #221.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
diff --git a/src/md4c.c b/src/md4c.c
index 35f5ea0..f325c79 100644
--- a/src/md4c.c
+++ b/src/md4c.c
@@ -3862,11 +3862,11 @@ md_analyze_dollar(MD_CTX* ctx, int mark_index)
         /* If the potential closer has a non-matching number of $, discard */
         MD_MARK* open = &ctx->marks[DOLLAR_OPENERS.head];
         MD_MARK* close = &ctx->marks[mark_index];
-
         int opener_index = DOLLAR_OPENERS.head;
-        md_rollback(ctx, opener_index, mark_index, MD_ROLLBACK_ALL);
+
         if (open->end - open->beg == close->end - close->beg) {
             /* We are the matching closer */
+            md_rollback(ctx, opener_index, mark_index, MD_ROLLBACK_ALL);
             md_resolve_range(ctx, &DOLLAR_OPENERS, opener_index, mark_index);
             return;
         }