Commit 0d7aeacc authored by Alexander Alekhin's avatar Alexander Alekhin

Merge pull request #9230 from alalek:mat_cleanup_on_exception

parents 0194d5a2 7f3eea63
......@@ -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)
......
......@@ -411,8 +411,9 @@ UMat::~UMat()
void UMat::deallocate()
{
u->currAllocator->deallocate(u);
UMatData* u_ = u;
u = NULL;
u_->currAllocator->deallocate(u_);
}
......
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