Commit bb23f79129470dfdb7f447b096bde7f4d5a78a88

Martin Mitas 2016-12-04T18:09:33

md_build_img_alt: Fix crash when dealing with some mark types. For some mark types, it is possible that subsequent mark has lower 'beg' then 'end' of the previous one. This typically happens when an opener mark is expanded to cover whole range to the closer.

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/md4c/md4c.c b/md4c/md4c.c
index 07e415d..81c438e 100644
--- a/md4c/md4c.c
+++ b/md4c/md4c.c
@@ -3288,7 +3288,7 @@ md_build_img_alt(MD_CTX* ctx, MD_MARK* mark, const MD_LINE* lines, int n_lines,
                 off = mark->end;
 
                 mark++;
-                while(!(mark->flags & MD_MARK_RESOLVED))
+                while(!(mark->flags & MD_MARK_RESOLVED) || mark->beg < off)
                     mark++;
             }
         }