Avoid accessing invalid iterator.
authorDejan Mircevski <deki@google.com>
Sat, 4 Jun 2016 01:46:19 +0000 (21:46 -0400)
committerDejan Mircevski <deki@google.com>
Sat, 4 Jun 2016 01:46:19 +0000 (21:46 -0400)
source/validate_cfg.cpp

index f9a1d90..e1f1191 100644 (file)
@@ -85,11 +85,11 @@ vector<const BasicBlock*> PostOrderSort(const BasicBlock& entry, size_t size) {
       staged.pop_back();
     } else {
       BasicBlock* child = *top.iter;
+      top.iter++;
       if (processed.find(child->get_id()) == end(processed)) {
         staged.emplace_back(block_info{child, begin(child->get_successors())});
         processed.insert(child->get_id());
       }
-      top.iter++;
     }
   }
   return out;