@@ -294,7 +294,6 @@ static bool validate_protocol(char protocol[], uint8_t *data, int rewind, int ma
294
294
static void postprocess_text (cmark_parser * parser , cmark_node * text ) {
295
295
size_t start = 0 ;
296
296
size_t offset = 0 ;
297
- size_t depth = 0 ;
298
297
// `text` is going to be split into a list of nodes containing shorter segments
299
298
// of text, so we detach the memory buffer from text and use `cmark_chunk_dup` to
300
299
// 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) {
307
306
size_t remaining = text -> as .literal .len ;
308
307
309
308
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
-
314
309
size_t link_end ;
315
310
uint8_t * at ;
316
311
bool auto_mailto = true;
@@ -356,7 +351,6 @@ static void postprocess_text(cmark_parser *parser, cmark_node *text) {
356
351
357
352
if (rewind == 0 ) {
358
353
offset += max_rewind + 1 ;
359
- depth ++ ;
360
354
continue ;
361
355
}
362
356
@@ -385,15 +379,13 @@ static void postprocess_text(cmark_parser *parser, cmark_node *text) {
385
379
(!cmark_isalpha (data [start + offset + max_rewind + link_end - 1 ]) &&
386
380
data [start + offset + max_rewind + link_end - 1 ] != '.' )) {
387
381
offset += max_rewind + link_end ;
388
- depth ++ ;
389
382
continue ;
390
383
}
391
384
392
385
link_end = autolink_delim (data + start + offset + max_rewind , link_end );
393
386
394
387
if (link_end == 0 ) {
395
388
offset += max_rewind + 1 ;
396
- depth ++ ;
397
389
continue ;
398
390
}
399
391
@@ -430,7 +422,6 @@ static void postprocess_text(cmark_parser *parser, cmark_node *text) {
430
422
start += offset + max_rewind + link_end ;
431
423
remaining -= offset + max_rewind + link_end ;
432
424
offset = 0 ;
433
- depth ++ ;
434
425
}
435
426
436
427
// Convert the reference to allocated memory.
0 commit comments