Skip to content

Commit f7e31f8

Browse files
jgmkevinbackhouse
authored andcommitted
Add MAX_INDENT for xml.
Otherwise we can get quadratic increase in size with deeply nested structures. See commonmark#355.
1 parent 828322d commit f7e31f8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/xml.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "syntax_extension.h"
1212

1313
#define BUFFER_SIZE 100
14+
#define MAX_INDENT 40
1415

1516
// Functions to convert cmark_nodes to XML strings.
1617

@@ -26,7 +27,7 @@ struct render_state {
2627

2728
static CMARK_INLINE void indent(struct render_state *state) {
2829
int i;
29-
for (i = 0; i < state->indent; i++) {
30+
for (i = 0; i < state->indent && i < MAX_INDENT; i++) {
3031
cmark_strbuf_putc(state->xml, ' ');
3132
}
3233
}

0 commit comments

Comments
 (0)