Commit 83a2b566 authored by Alexander Alekhin's avatar Alexander Alekhin

fix memory leak for Mat::getUMat() operation

parent 22146e4b
...@@ -3112,8 +3112,7 @@ UMat::UMat(const UMat& m) ...@@ -3112,8 +3112,7 @@ UMat::UMat(const UMat& m)
: flags(m.flags), dims(m.dims), rows(m.rows), cols(m.cols), allocator(m.allocator), : flags(m.flags), dims(m.dims), rows(m.rows), cols(m.cols), allocator(m.allocator),
u(m.u), offset(m.offset), size(&rows) u(m.u), offset(m.offset), size(&rows)
{ {
if( u ) addref();
CV_XADD(&(u->urefcount), 1);
if( m.dims <= 2 ) if( m.dims <= 2 )
{ {
step[0] = m.step[0]; step[1] = m.step[1]; step[0] = m.step[0]; step[1] = m.step[1];
...@@ -3148,8 +3147,7 @@ UMat& UMat::operator = (const UMat& m) ...@@ -3148,8 +3147,7 @@ UMat& UMat::operator = (const UMat& m)
{ {
if( this != &m ) if( this != &m )
{ {
if( m.u ) const_cast<UMat&>(m).addref();
CV_XADD(&(m.u->urefcount), 1);
release(); release();
flags = m.flags; flags = m.flags;
if( dims <= 2 && m.dims <= 2 ) if( dims <= 2 && m.dims <= 2 )
......
...@@ -191,7 +191,6 @@ public: ...@@ -191,7 +191,6 @@ public:
bool allocate(UMatData* u, int /*accessFlags*/) const bool allocate(UMatData* u, int /*accessFlags*/) const
{ {
if(!u) return false; if(!u) return false;
CV_XADD(&u->urefcount, 1);
return true; return true;
} }
......
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