mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 15:23:05 +04:00
core: verify length check from vector to InputArray
This commit is contained in:
@@ -107,7 +107,10 @@ inline _InputArray::_InputArray(const std::vector<UMat>& vec) { init(+STD_VECTOR
|
||||
|
||||
template<typename _Tp> inline
|
||||
_InputArray::_InputArray(const std::vector<_Tp>& vec)
|
||||
{ init(FIXED_TYPE + STD_VECTOR + traits::Type<_Tp>::value + ACCESS_READ, &vec); }
|
||||
{
|
||||
CV_CheckLE(vec.size(), static_cast<size_t>(std::numeric_limits<int>::max()), "Must not be larger than INT_MAX");
|
||||
init(FIXED_TYPE + STD_VECTOR + traits::Type<_Tp>::value + ACCESS_READ, &vec);
|
||||
}
|
||||
|
||||
template<typename _Tp, std::size_t _Nm> inline
|
||||
_InputArray::_InputArray(const std::array<_Tp, _Nm>& arr)
|
||||
|
||||
@@ -1471,6 +1471,14 @@ TEST(Core_InputArray, empty)
|
||||
ASSERT_TRUE( _InputArray(data).empty() );
|
||||
}
|
||||
|
||||
TEST(Core_InputArray, convert_from_vector_over2GB)
|
||||
{
|
||||
applyTestTag(CV_TEST_TAG_MEMORY_6GB);
|
||||
// empty buffer more than 2GB size
|
||||
std::vector<uint8_t> buf(size_t(INT_MAX) + 4096);
|
||||
EXPECT_ANY_THROW(auto work = _InputArray(buf));
|
||||
}
|
||||
|
||||
TEST(Core_CopyMask, bug1918)
|
||||
{
|
||||
Mat_<unsigned char> tmpSrc(100,100);
|
||||
|
||||
@@ -619,4 +619,13 @@ TEST(Imgcodecs_Params, imencode_regression_22752)
|
||||
EXPECT_ANY_THROW(cv::imencode("test.jpg", img, buf, params)); // parameters size or missing JPEG codec
|
||||
}
|
||||
|
||||
TEST(Imgcodecs, decode_over2GB)
|
||||
{
|
||||
applyTestTag(CV_TEST_TAG_MEMORY_6GB);
|
||||
// empty buffer more than 2GB size
|
||||
std::vector<uint8_t> buf(size_t(INT_MAX) + 4096);
|
||||
cv::Mat dst;
|
||||
EXPECT_THROW(dst = cv::imdecode(buf, cv::IMREAD_COLOR), cv::Exception);
|
||||
}
|
||||
|
||||
}} // namespace
|
||||
|
||||
Reference in New Issue
Block a user