From 67619a5d5c71c44565a9a0413aaf78f9baece528 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 28 Oct 2014 23:03:02 -0700 Subject: Disallow bracketed labels nested more than 1000 deep. For performance reasons. See #166. --- src/inlines.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/inlines.c b/src/inlines.c index 26eb02a..9216979 100644 --- a/src/inlines.c +++ b/src/inlines.c @@ -594,7 +594,8 @@ static int link_label(subject* subj, chunk *raw_label) advance(subj); // advance past [ unsigned char c; - while ((c = peek_char(subj)) && (c != ']' || nestlevel > 0)) { + while ((c = peek_char(subj)) && + (c != ']' || (nestlevel > 0 && nestlevel < STACK_LIMIT))) { switch (c) { case '`': tmp = handle_backticks(subj); @@ -622,7 +623,7 @@ static int link_label(subject* subj, chunk *raw_label) advance(subj); } } - if (c == ']') { + if (nestlevel == 0 && c == ']') { *raw_label = chunk_dup(&subj->input, startpos + 1, subj->pos - (startpos + 1)); subj->label_nestlevel = 0; advance(subj); // advance past ] -- cgit v1.2.3