mirror of
https://github.com/opencv/opencv.git
synced 2024-11-28 21:20:18 +08:00
matrix.cpp::setSize(): fixed out-of-bounds access on cv::Mat steps
This commit is contained in:
parent
a5b8f163d7
commit
102d8f67cd
@ -237,12 +237,19 @@ void setSize( Mat& m, int _dims, const int* _sz, const size_t* _steps, bool auto
|
||||
|
||||
if( _steps )
|
||||
{
|
||||
if (_steps[i] % esz1 != 0)
|
||||
if (i < _dims-1)
|
||||
{
|
||||
CV_Error(Error::BadStep, "Step must be a multiple of esz1");
|
||||
}
|
||||
if (_steps[i] % esz1 != 0)
|
||||
{
|
||||
CV_Error_(Error::BadStep, ("Step %zu for dimension %d must be a multiple of esz1 %zu", _steps[i], i, esz1));
|
||||
}
|
||||
|
||||
m.step.p[i] = i < _dims-1 ? _steps[i] : esz;
|
||||
m.step.p[i] = _steps[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
m.step.p[i] = esz;
|
||||
}
|
||||
}
|
||||
else if( autoSteps )
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user