Fix segmentation fault in cv::Mat::forEach
authorjexner <jexner@techfak.uni-bielefeld.de>
Thu, 23 Mar 2017 17:48:59 +0000 (18:48 +0100)
committerjexner <jexner@techfak.uni-bielefeld.de>
Thu, 23 Mar 2017 17:48:59 +0000 (18:48 +0100)
This issue concerns only matrices with more dimensions than columns.
See https://github.com/opencv/opencv/issues/8447

modules/core/include/opencv2/core/utility.hpp

index 93d599c..bc33f03 100644 (file)
@@ -507,7 +507,7 @@ void Mat::forEach_impl(const Functor& operation) {
                     this->rowCall2(row, COLS);
                 }
             } else {
-                std::vector<int> idx(COLS); /// idx is modified in this->rowCall
+                std::vector<int> idx(DIMS); /// idx is modified in this->rowCall
                 idx[DIMS - 2] = range.start - 1;
 
                 for (int line_num = range.start; line_num < range.end; ++line_num) {