Skip to content

Commit

Permalink
fix: no infinite loop caused by overlapped delimiter range
Browse files Browse the repository at this point in the history
  • Loading branch information
ikatyang committed Jan 17, 2021
1 parent 97e1e61 commit f9e9749
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
16 changes: 16 additions & 0 deletions corpus/issues.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,19 @@ ss_*.
(text)))
(paragraph
(text)))

================================================================================
#16 - infinite loop caused by overlapped delimiter range
================================================================================
[(https://example.com/foo[bar]

--------------------------------------------------------------------------------

(document
(paragraph
(text)
(uri_autolink
(text))
(link
(link_text
(text)))))
5 changes: 4 additions & 1 deletion src/tree_sitter_markdown/inline_scan.cc
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,10 @@ bool scn_ext_aut_lnk(Lexer &lxr, InlineDelimiterList &inl_dlms, InlineContextSta
LexedPosition bgn_pos = lxr.cur_pos();
bool in_tbl = is_in_tbl(blk_ctx_stk);
InlineDelimiterList::Iterator ctx_itr = inl_ctx_stk.back().dlm_itr();
while (!is_wht_chr(lxr.lka_chr()) && lxr.lka_chr() != '<' && !MAYBE_TBL_COL_SEP()) {
while (
(nxt_inl_dlm_itr == inl_dlms.end() || lxr.cur_idx() < nxt_inl_dlm_itr->pos().idx())
&& !is_wht_chr(lxr.lka_chr()) && lxr.lka_chr() != '<' && !MAYBE_TBL_COL_SEP()
) {
if (lxr.lka_chr() == '(') {
ctx_itr->set_ctm_dat(ctx_itr->ctm_dat() - 1);
} else if (lxr.lka_chr() == ')') {
Expand Down

0 comments on commit f9e9749

Please sign in to comment.