https://bugs.kde.org/show_bug.cgi?id=399923

--- Comment #242 from caulier.gil...@gmail.com ---
Maik, 

The problem from this file can be relevant of the long time problem located in
DSharedData container and never fixed.

Look this clang report:

https://www.digikam.org/reports/clang/master/

==> Memory error; Use-after-free;
mnt/devel/GIT/6.x/core/libs/dimg/dshareddata.h; operator
Digikam::DImg::Private; ligne 120

And look well the analysis. Clang crying about this operator :

inline operator T* ()
{
    return d; <== Use of memory after it is freed
}

...because the memory is released here :

inline DSharedDataPointer& operator=(T* const o)
{
   delete assign(o);    <=== Memory is released 
   return *this;
}

... when this detach function is called :

void DImg::detach()
{
   if (!m_priv->hasMoreReferences())
   {
      return;
   }

   DSharedDataPointer<Private> old = m_priv; <=== Calling
'DSharedDataPointer::operator='; Returning; memory was released       
   m_priv = new Private;

   copyImageData(old); <=== Calling 'DSharedDataPointer::operator
Digikam::DImg::Private *' !!!!!!!! BOUM !!!!!!!!
   copyMetaData(old);

   if (old->data)
   {
       size_t size = allocateData();
       memcpy(m_priv->data, old->data, size);
   }
}

Gilles

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to