Skip to content

Commit

Permalink
Pass exivData as argument to avoid crash in exiv2 library
Browse files Browse the repository at this point in the history
This should fix the bug reported at Exiv2/exiv2#2649.

Exiv2 will be made more robust against this, but this commit should get
Gwenview unstuck in the meantime.

BUG: 470880
FIXED-IN: 23.04.1
  • Loading branch information
kevinbackhouse authored and Pointedstick committed Jun 28, 2023
1 parent 9c1093c commit d2869e8
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/imagemetainfomodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ struct ImageMetaInfoModelPrivate {
}

template<class Container, class Iterator>
void fillExivGroup(const QModelIndex &parent, MetaInfoGroup *group, const Container &container)
void fillExivGroup(const QModelIndex &parent, MetaInfoGroup *group, const Container &container, const Exiv2::ExifData &exifData)
{
// key aren't always unique (for example, "Iptc.Application2.Keywords"
// may appear multiple times) so we can't know how many rows we will
Expand All @@ -279,7 +279,7 @@ struct ImageMetaInfoModelPrivate {
const QString key = QString::fromUtf8(it->key().c_str());
const QString label = QString::fromLocal8Bit(it->tagLabel().c_str());
std::ostringstream stream;
stream << *it;
it->write(stream, &exifData);
const QString value = QString::fromLocal8Bit(stream.str().c_str());

EntryHash::iterator hashIt = hash.find(key);
Expand Down Expand Up @@ -436,19 +436,19 @@ void ImageMetaInfoModel::setExiv2Image(const Exiv2::Image *image)

d->setGroupEntryValue(GeneralGroup, QStringLiteral("General.Comment"), QString::fromUtf8(image->comment().c_str()));

const Exiv2::ExifData &exifData = image->exifData();
if (image->checkMode(Exiv2::mdExif) & Exiv2::amRead) {
const Exiv2::ExifData &exifData = image->exifData();
d->fillExivGroup<Exiv2::ExifData, Exiv2::ExifData::const_iterator>(exifIndex, exifGroup, exifData);
d->fillExivGroup<Exiv2::ExifData, Exiv2::ExifData::const_iterator>(exifIndex, exifGroup, exifData, exifData);
}

if (image->checkMode(Exiv2::mdIptc) & Exiv2::amRead) {
const Exiv2::IptcData &iptcData = image->iptcData();
d->fillExivGroup<Exiv2::IptcData, Exiv2::IptcData::const_iterator>(iptcIndex, iptcGroup, iptcData);
d->fillExivGroup<Exiv2::IptcData, Exiv2::IptcData::const_iterator>(iptcIndex, iptcGroup, iptcData, exifData);
}

if (image->checkMode(Exiv2::mdXmp) & Exiv2::amRead) {
const Exiv2::XmpData &xmpData = image->xmpData();
d->fillExivGroup<Exiv2::XmpData, Exiv2::XmpData::const_iterator>(xmpIndex, xmpGroup, xmpData);
d->fillExivGroup<Exiv2::XmpData, Exiv2::XmpData::const_iterator>(xmpIndex, xmpGroup, xmpData, exifData);
}
}

Expand Down

0 comments on commit d2869e8

Please sign in to comment.