Blame SOURCES/opencv-3.4.6-cvSaveImage.patch

0f18d9
From 6e1da2ef91907678159d40f600a56094c4d196b9 Mon Sep 17 00:00:00 2001
0f18d9
From: Zhuo Zhang <zchrissirhcz@gmail.com>
0f18d9
Date: Fri, 25 Dec 2020 00:58:16 +0800
0f18d9
Subject: [PATCH] Merge pull request #19203 from zchrissirhcz:fix-cvSaveImage
0f18d9
0f18d9
Fix cvSaveImage( ) function bug
0f18d9
0f18d9
* fix cvSaveImage crash
0f18d9
0f18d9
* replace emplace_back with {}, no C++11 required
0f18d9
0f18d9
* fix MacOSX build with vector's push_back
0f18d9
---
0f18d9
 modules/imgcodecs/src/loadsave.cpp | 4 +++-
0f18d9
 1 file changed, 3 insertions(+), 1 deletion(-)
0f18d9
0f18d9
diff --git a/modules/imgcodecs/src/loadsave.cpp b/modules/imgcodecs/src/loadsave.cpp
0f18d9
index 4e626cd2165b..44c458c7273c 100644
0f18d9
--- a/modules/imgcodecs/src/loadsave.cpp
0f18d9
+++ b/modules/imgcodecs/src/loadsave.cpp
0f18d9
@@ -1001,7 +1001,9 @@ cvSaveImage( const char* filename, const CvArr* arr, const int* _params )
0f18d9
         for( ; _params[i] > 0; i += 2 )
0f18d9
             CV_Assert(static_cast<size_t>(i) < cv::CV_IO_MAX_IMAGE_PARAMS*2); // Limit number of params for security reasons
0f18d9
     }
0f18d9
-    return cv::imwrite_(filename, cv::cvarrToMat(arr),
0f18d9
+    std::vector<cv::Mat> img_vec;
0f18d9
+    img_vec.push_back(cv::cvarrToMat(arr));
0f18d9
+    return cv::imwrite_(filename, img_vec,
0f18d9
         i > 0 ? std::vector<int>(_params, _params+i) : std::vector<int>(),
0f18d9
         CV_IS_IMAGE(arr) && ((const IplImage*)arr)->origin == IPL_ORIGIN_BL );
0f18d9
 }