diff --git a/modules/ml/src/data.cpp b/modules/ml/src/data.cpp index a5dd101f1d..d8b41ed91c 100644 --- a/modules/ml/src/data.cpp +++ b/modules/ml/src/data.cpp @@ -904,7 +904,7 @@ public: if( s ) { j = s[i]; - CV_Assert( 0 <= j && j < nsamples ); + CV_Assert( 0 <= j && j < ((layout == ROW_SAMPLE) ? samples.rows : samples.cols) ); } values[i] = src[j*sstep]; if( values[i] == MISSED_VAL )