From 0dfab6bbd0c7bf5e7606c372b9c5e3b3b5768ebe Mon Sep 17 00:00:00 2001
From: berak <px1704@web.de>
Date: Thu, 28 Nov 2019 20:33:58 +0100
Subject: [PATCH] ml: fix check in SVM::trainAuto

---
 modules/ml/src/svm.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/modules/ml/src/svm.cpp b/modules/ml/src/svm.cpp
index 4c3ff2a319..3659b9c557 100644
--- a/modules/ml/src/svm.cpp
+++ b/modules/ml/src/svm.cpp
@@ -1451,7 +1451,7 @@ public:
             sortSamplesByClasses( _samples, _responses, sidx_all, class_ranges );
 
             //check that while cross-validation there were the samples from all the classes
-            if( class_ranges[class_count] <= 0 )
+            if ((int)class_ranges.size() < class_count + 1)
                 CV_Error( CV_StsBadArg, "While cross-validation one or more of the classes have "
                 "been fell out of the sample. Try to reduce <Params::k_fold>" );