core: preserve sizes values (fixes #5991)
_sizes can point to internal structure which is destroyed by release() call
This commit is contained in:
parent
96f5a930f4
commit
2978a16c85
@ -397,6 +397,14 @@ void Mat::create(int d, const int* _sizes, int _type)
|
||||
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();
|
||||
if( d == 0 )
|
||||
return;
|
||||
@ -4899,6 +4907,13 @@ void SparseMat::create(int d, const int* _sizes, int _type)
|
||||
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();
|
||||
flags = MAGIC_VAL | _type;
|
||||
hdr = new Hdr(d, _sizes, _type);
|
||||
|
@ -345,6 +345,14 @@ void UMat::create(int d, const int* _sizes, int _type, UMatUsageFlags _usageFlag
|
||||
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();
|
||||
if( d == 0 )
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user