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

pull/9230/head
Alexander Alekhin 7 years ago
parent 0194d5a2d5
commit 7f3eea6325
  1. 8
      modules/core/src/matrix.cpp
  2. 3
      modules/core/src/umatrix.cpp

@ -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);
u = NULL;
{
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)

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

Loading…
Cancel
Save