diff options
author | John MacFarlane <jgm@berkeley.edu> | 2014-10-28 23:03:02 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2014-10-28 23:03:02 -0700 |
commit | 67619a5d5c71c44565a9a0413aaf78f9baece528 (patch) | |
tree | 7b299e17e91d6cbed62ba00754fdbfd4e2629e32 | |
parent | 9253c0eab573e5ca0d37e4b1db77d3b0bfcf3be6 (diff) |
Disallow bracketed labels nested more than 1000 deep.
For performance reasons. See #166.
-rw-r--r-- | src/inlines.c | 5 |
1 files changed, 3 insertions, 2 deletions
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 ] |