Commit d4802e1b authored by Kevin Modzelewski's avatar Kevin Modzelewski

Merge pull request #81 from undingen/iterator_invalid

Remove read from freed memory
parents d750c9eb 867eef3d
...@@ -808,7 +808,10 @@ public: ...@@ -808,7 +808,10 @@ public:
virtual void accept(ASTVisitor* v); virtual void accept(ASTVisitor* v);
virtual void accept_stmt(StmtVisitor* v); virtual void accept_stmt(StmtVisitor* v);
AST_Jump() : AST_stmt(AST_TYPE::Jump) {} AST_Jump() : AST_stmt(AST_TYPE::Jump) {
lineno = -1;
col_offset = -1;
}
static const AST_TYPE::AST_TYPE TYPE = AST_TYPE::Jump; static const AST_TYPE::AST_TYPE TYPE = AST_TYPE::Jump;
}; };
......
...@@ -1654,7 +1654,10 @@ CFG* computeCFG(AST_TYPE::AST_TYPE root_type, std::vector<AST_stmt*> body) { ...@@ -1654,7 +1654,10 @@ CFG* computeCFG(AST_TYPE::AST_TYPE root_type, std::vector<AST_stmt*> body) {
// and can make the analyses more efficient. // and can make the analyses more efficient.
// The extra blocks would get merged by LLVM passes, so I'm not sure // The extra blocks would get merged by LLVM passes, so I'm not sure
// how much overall improvement there is. // how much overall improvement there is.
for (CFGBlock* b : rtn->blocks) {
// Must evaluate end() on every iteration because erase() will invalidate the end.
for (auto it = rtn->blocks.begin(); it != rtn->blocks.end(); ++it) {
CFGBlock* b = *it;
while (b->successors.size() == 1) { while (b->successors.size() == 1) {
CFGBlock* b2 = b->successors[0]; CFGBlock* b2 = b->successors[0];
if (b2->predecessors.size() != 1) if (b2->predecessors.size() != 1)
......
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