You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
opencv/SOURCES/opencv-3.4.6-cvSaveImage.patch

32 lines
1.3 KiB

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