calib3d/imgproc: add GCGraph::maxFlow() missing empty checks
authorAlexander Alekhin <alexander.a.alekhin@gmail.com>
Thu, 1 Oct 2020 15:20:32 +0000 (15:20 +0000)
committerAlexander Alekhin <alexander.a.alekhin@gmail.com>
Fri, 2 Oct 2020 05:15:20 +0000 (05:15 +0000)
modules/imgproc/src/gcgraph.hpp

index 16c25de..8730e1f 100644 (file)
@@ -152,6 +152,8 @@ void GCGraph<TWeight>::addTermWeights( int i, TWeight sourceW, TWeight sinkW )
 template <class TWeight>
 TWeight GCGraph<TWeight>::maxFlow()
 {
+    CV_Assert(!vtcs.empty());
+    CV_Assert(!edges.empty());
     const int TERMINAL = -1, ORPHAN = -2;
     Vtx stub, *nilNode = &stub, *first = nilNode, *last = nilNode;
     int curr_ts = 0;