[Digikam-devel] Several crashes of digikam

Marcel Wiesweg marcel.wiesweg at gmx.de
Sun May 21 20:49:04 BST 2006


> Like suggested Exiv2 author, there is a problem in dmetaloader.cpp lines
> 87, 94 and 101 : reference = reference !!! Look the message from Andreas
> below :
>
> // ------------------------------------------------------------------------
> ...
> I suspect the problem is here:
>
> bool DMetaLoader::loadWithExiv2(const QString& filePath)
> {
>     try
>     {
>         if (filePath.isEmpty())
>             return false;
>
>         Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open((const
> char*) (QFile::encodeName(filePath))); image->readMetadata();
>
>         // Image comments ---------------------------------
>
> [snip]
>
>         // Exif metadata ----------------------------------
>
>         exifMetadata() = image->exifData();
>
> Both, exifMetadata() and image->exifData() return a reference only, the
> metadata is not copied, it is still in the container owned by the image.
>
>         if (!exifMetadata().empty())
>             m_hasExif = true;
>
> [snip]
>
>         return true;
>     }
>
> The Image::AutoPtr goes out of scope and the image is deleted. All
> references to the metadata inside the image become invalid and future
> access through such references have undefined behaviour.
>
> Could that be it?

If you check with gdb, you can see that ExifData::operator= is actually 
called. Operator= is doing a deep copy.
Reference = reference should be all right, operator= takes a reference, and 
for the left-hand variable operator= is called. Or am I missing the point?

I cannot reproduce the crashes, and valgrind does not give me any errors.

Marcel

> ...
> // ------------------------------------------------------------------------
>
> It's easy to fix it, and this is must be done in all cases. Marcel, if you
> have some time to do it, feel free to do, i'm busy today.
>
> Gilles



More information about the Digikam-devel mailing list