Commit 7735b4bd authored by Robert Ricci's avatar Robert Ricci

Fix some really dumb segfaults if link endpoints didn't exist.

parent 8bf48bc3
......@@ -193,6 +193,16 @@ int parse_ptop(tb_pgraph &PG, tb_sgraph &SG, istream& i)
}
#define ISSWITCH(n) (n->types.find("switch") != n->types.end())
// Check to make sure the nodes in the link actually exist
if (pname2vertex.find(src) == pname2vertex.end()) {
ptop_error("Bad link line, non-existent node.");
continue;
}
if (pname2vertex.find(dst) == pname2vertex.end()) {
ptop_error("Bad link line, non-existent node.");
continue;
}
pvertex srcv = pname2vertex[src];
pvertex dstv = pname2vertex[dst];
tb_pnode *srcnode = get(pvertex_pmap,srcv);
......
......@@ -162,6 +162,16 @@ int parse_top(tb_vgraph &VG, istream& i)
}
vedge e;
// Check to make sure the nodes in the link actually exist
if (vname2vertex.find(src) == vname2vertex.end()) {
top_error("Bad link line, non-existent node.");
continue;
}
if (vname2vertex.find(dst) == vname2vertex.end()) {
top_error("Bad link line, non-existent node.");
continue;
}
vvertex node1 = vname2vertex[src];
vvertex node2 = vname2vertex[dst];
e = add_edge(node1,node2,VG).first;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment