core: fix Mat/UMat cleanup on exceptions in deallocate()

This commit is contained in:
Alexander Alekhin 2017-07-25 12:26:53 +03:00
parent 0194d5a2d5
commit 7f3eea6325
2 changed files with 7 additions and 4 deletions

View File

@ -60,7 +60,6 @@ void MatAllocator::unmap(UMatData* u) const
if(u->urefcount == 0 && u->refcount == 0)
{
deallocate(u);
u = NULL;
}
}
@ -461,8 +460,11 @@ void Mat::copySize(const Mat& m)
void Mat::deallocate()
{
if(u)
(u->currAllocator ? u->currAllocator : allocator ? allocator : getDefaultAllocator())->unmap(u);
{
UMatData* u_ = u;
u = NULL;
(u_->currAllocator ? u_->currAllocator : allocator ? allocator : getDefaultAllocator())->unmap(u_);
}
}
Mat::Mat(const Mat& m, const Range& _rowRange, const Range& _colRange)

View File

@ -411,8 +411,9 @@ UMat::~UMat()
void UMat::deallocate()
{
u->currAllocator->deallocate(u);
UMatData* u_ = u;
u = NULL;
u_->currAllocator->deallocate(u_);
}