core: preserve sizes values (fixes #5991)

_sizes can point to internal structure which is destroyed
by release() call
This commit is contained in:
Alexander Alekhin 2016-01-26 13:59:10 +03:00
parent 96f5a930f4
commit 2978a16c85
2 changed files with 23 additions and 0 deletions

View File

@ -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);

View File

@ -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;