[opencv] 149/251: core: fix Mat/UMat cleanup on exceptions in deallocate()

Nobuhiro Iwamatsu iwamatsu at moszumanska.debian.org
Sun Aug 27 23:27:37 UTC 2017


This is an automated email from the git hooks/post-receive script.

iwamatsu pushed a commit to annotated tag 3.3.0
in repository opencv.

commit 7f3eea6325205b33ab60f6ce9edbd0442a852b41
Author: Alexander Alekhin <alexander.alekhin at intel.com>
Date:   Tue Jul 25 12:26:53 2017 +0300

    core: fix Mat/UMat cleanup on exceptions in deallocate()
---
 modules/core/src/matrix.cpp  | 8 +++++---
 modules/core/src/umatrix.cpp | 3 ++-
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/modules/core/src/matrix.cpp b/modules/core/src/matrix.cpp
index 0e18ad2..bc85170 100644
--- a/modules/core/src/matrix.cpp
+++ b/modules/core/src/matrix.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)
diff --git a/modules/core/src/umatrix.cpp b/modules/core/src/umatrix.cpp
index 239e461..58f7390 100644
--- a/modules/core/src/umatrix.cpp
+++ b/modules/core/src/umatrix.cpp
@@ -411,8 +411,9 @@ UMat::~UMat()
 
 void UMat::deallocate()
 {
-    u->currAllocator->deallocate(u);
+    UMatData* u_ = u;
     u = NULL;
+    u_->currAllocator->deallocate(u_);
 }
 
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/opencv.git



More information about the debian-science-commits mailing list