Merge pull request #16992 from afowles:fix-forEach-segfault

* Fixed divide by zero error in forEach

* Dedicated assertion for !empty
This commit is contained in:
Adam Fowles 2020-04-06 10:49:02 -04:00 committed by GitHub
parent 99d29c9d39
commit 8334932a26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -622,6 +622,7 @@ void Mat::forEach_impl(const Functor& operation) {
// or (_Tp&, void*) <- in case you don't need current idx.
}
CV_Assert(!empty());
CV_Assert(this->total() / this->size[this->dims - 1] <= INT_MAX);
const int LINES = static_cast<int>(this->total() / this->size[this->dims - 1]);