Skip to content

Commit

Permalink
Merge pull request #4799 from aG0aep6G/14717
Browse files Browse the repository at this point in the history
fix issue 14717 - Ddoc macro recursion limit too low
  • Loading branch information
9rnsr committed Jul 5, 2015
2 parents 64c473c + da73aae commit ef51538
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/macro.c
Expand Up @@ -18,6 +18,7 @@
#include <ctype.h>
#include <assert.h>

#include "errors.h"
#include "rmem.h"
#include "root.h"

Expand Down Expand Up @@ -232,9 +233,15 @@ void Macro::expand(OutBuffer *buf, size_t start, size_t *pend,
printf("Buf is: '%.*s'\n", *pend - start, buf->data + start);
#endif

// limit recursive expansion
static int nest;
if (nest > 100) // limit recursive expansion
static const int nestLimit = 1000;
if (nest > nestLimit)
{
error(Loc(), "DDoc macro expansion limit exceeded; more than %d "
"expansions.", nestLimit);
return;
}
nest++;

size_t end = *pend;
Expand Down
2 changes: 2 additions & 0 deletions src/magicport.json
Expand Up @@ -1948,6 +1948,8 @@
"core.stdc.ctype",
"core.stdc.string",
"doc",
"errors",
"globals",
"root.outbuffer",
"root.rmem",
"utf"
Expand Down

0 comments on commit ef51538

Please sign in to comment.