@@ -294,7 +294,6 @@ static bool validate_protocol(char protocol[], uint8_t *data, int rewind, int ma
294294static void postprocess_text (cmark_parser * parser , cmark_node * text ) {
295295 size_t start = 0 ;
296296 size_t offset = 0 ;
297- size_t depth = 0 ;
298297 // `text` is going to be split into a list of nodes containing shorter segments
299298 // of text, so we detach the memory buffer from text and use `cmark_chunk_dup` to
300299 // create references to it. Later, `cmark_chunk_to_cstr` is used to convert
@@ -307,10 +306,6 @@ static void postprocess_text(cmark_parser *parser, cmark_node *text) {
307306 size_t remaining = text -> as .literal .len ;
308307
309308 while (true) {
310- // postprocess_text can recurse very deeply if there is a very long line of
311- // '@' only. Stop at a reasonable depth to ensure it cannot crash.
312- if (depth > 1000 ) break ;
313-
314309 size_t link_end ;
315310 uint8_t * at ;
316311 bool auto_mailto = true;
@@ -356,7 +351,6 @@ static void postprocess_text(cmark_parser *parser, cmark_node *text) {
356351
357352 if (rewind == 0 ) {
358353 offset += max_rewind + 1 ;
359- depth ++ ;
360354 continue ;
361355 }
362356
@@ -385,15 +379,13 @@ static void postprocess_text(cmark_parser *parser, cmark_node *text) {
385379 (!cmark_isalpha (data [start + offset + max_rewind + link_end - 1 ]) &&
386380 data [start + offset + max_rewind + link_end - 1 ] != '.' )) {
387381 offset += max_rewind + link_end ;
388- depth ++ ;
389382 continue ;
390383 }
391384
392385 link_end = autolink_delim (data + start + offset + max_rewind , link_end );
393386
394387 if (link_end == 0 ) {
395388 offset += max_rewind + 1 ;
396- depth ++ ;
397389 continue ;
398390 }
399391
@@ -430,7 +422,6 @@ static void postprocess_text(cmark_parser *parser, cmark_node *text) {
430422 start += offset + max_rewind + link_end ;
431423 remaining -= offset + max_rewind + link_end ;
432424 offset = 0 ;
433- depth ++ ;
434425 }
435426
436427 // Convert the reference to allocated memory.
0 commit comments