mirror of
https://github.com/boostorg/graph.git
synced 2025-05-09 15:03:59 +00:00
max_subgraph_nesting_level in read_graphviz_new
This commit is contained in:
parent
9c0ceda4c8
commit
c71ceb8486
@ -53,6 +53,7 @@ namespace boost
|
||||
|
||||
namespace read_graphviz_detail
|
||||
{
|
||||
static const long max_subgraph_nesting_level = 255;
|
||||
struct token
|
||||
{
|
||||
enum token_type
|
||||
@ -527,6 +528,7 @@ namespace read_graphviz_detail
|
||||
std::map< subgraph_name, subgraph_info > subgraphs;
|
||||
std::string current_subgraph_name;
|
||||
int sgcounter; // Counter for anonymous subgraphs
|
||||
long sgnesting_level;
|
||||
std::set< std::pair< node_name, node_name > >
|
||||
existing_edges; // Used for checking in strict graphs
|
||||
|
||||
@ -538,7 +540,7 @@ namespace read_graphviz_detail
|
||||
subgraph_member_list& current_members() { return current().members; }
|
||||
|
||||
parser(const std::string& gr, parser_result& result)
|
||||
: the_tokenizer(gr), lookahead(), r(result), sgcounter(0)
|
||||
: the_tokenizer(gr), lookahead(), r(result), sgcounter(0), sgnesting_level(0)
|
||||
{
|
||||
current_subgraph_name = "___root___";
|
||||
current() = subgraph_info(); // Initialize root graph
|
||||
@ -803,6 +805,10 @@ namespace read_graphviz_detail
|
||||
return name;
|
||||
}
|
||||
subgraph_name old_sg = current_subgraph_name;
|
||||
if (++sgnesting_level > max_subgraph_nesting_level)
|
||||
{
|
||||
error("Exceeded maximum subgraph nesting level");
|
||||
}
|
||||
current_subgraph_name = name;
|
||||
if (first_token.type != token::left_brace)
|
||||
{
|
||||
@ -817,6 +823,7 @@ namespace read_graphviz_detail
|
||||
else
|
||||
error("Wanted right brace to end subgraph");
|
||||
current_subgraph_name = old_sg;
|
||||
sgnesting_level -= 1;
|
||||
return name;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user