Commit 2978a16c authored by Alexander Alekhin's avatar Alexander Alekhin

core: preserve sizes values (fixes #5991)

_sizes can point to internal structure which is destroyed
by release() call
parent 96f5a930
...@@ -397,6 +397,14 @@ void Mat::create(int d, const int* _sizes, int _type) ...@@ -397,6 +397,14 @@ void Mat::create(int d, const int* _sizes, int _type)
return; return;
} }
int _sizes_backup[CV_MAX_DIM]; // #5991
if (_sizes == (this->size.p))
{
for(i = 0; i < d; i++ )
_sizes_backup[i] = _sizes[i];
_sizes = _sizes_backup;
}
release(); release();
if( d == 0 ) if( d == 0 )
return; return;
...@@ -4899,6 +4907,13 @@ void SparseMat::create(int d, const int* _sizes, int _type) ...@@ -4899,6 +4907,13 @@ void SparseMat::create(int d, const int* _sizes, int _type)
return; return;
} }
} }
int _sizes_backup[CV_MAX_DIM]; // #5991
if (_sizes == hdr->size)
{
for(i = 0; i < d; i++ )
_sizes_backup[i] = _sizes[i];
_sizes = _sizes_backup;
}
release(); release();
flags = MAGIC_VAL | _type; flags = MAGIC_VAL | _type;
hdr = new Hdr(d, _sizes, _type); hdr = new Hdr(d, _sizes, _type);
......
...@@ -345,6 +345,14 @@ void UMat::create(int d, const int* _sizes, int _type, UMatUsageFlags _usageFlag ...@@ -345,6 +345,14 @@ void UMat::create(int d, const int* _sizes, int _type, UMatUsageFlags _usageFlag
return; return;
} }
int _sizes_backup[CV_MAX_DIM]; // #5991
if (_sizes == (this->size.p))
{
for(i = 0; i < d; i++ )
_sizes_backup[i] = _sizes[i];
_sizes = _sizes_backup;
}
release(); release();
if( d == 0 ) if( d == 0 )
return; return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment