Fix resource leak reported by Coverity (CID 186465)
This commit is contained in:
@@ -1439,16 +1439,16 @@ int ImageIO::saveTIFF (Glib::ustring fname, int bps, bool uncompressed)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (iptcdata) {
|
if (iptcdata) {
|
||||||
rtexif::Tag* iptcTag = new rtexif::Tag (nullptr, rtexif::lookupAttrib (rtexif::ifdAttribs, "IPTCData"));
|
rtexif::Tag iptcTag(nullptr, rtexif::lookupAttrib (rtexif::ifdAttribs, "IPTCData"));
|
||||||
iptcTag->initLongArray((char*)iptcdata, iptclen);
|
iptcTag.initLongArray((char*)iptcdata, iptclen);
|
||||||
#if __BYTE_ORDER__==__ORDER_LITTLE_ENDIAN__
|
#if __BYTE_ORDER__==__ORDER_LITTLE_ENDIAN__
|
||||||
bool needsReverse = exifRoot && exifRoot->getOrder() == rtexif::MOTOROLA;
|
bool needsReverse = exifRoot && exifRoot->getOrder() == rtexif::MOTOROLA;
|
||||||
#else
|
#else
|
||||||
bool needsReverse = exifRoot && exifRoot->getOrder() == rtexif::INTEL;
|
bool needsReverse = exifRoot && exifRoot->getOrder() == rtexif::INTEL;
|
||||||
#endif
|
#endif
|
||||||
if (needsReverse) {
|
if (needsReverse) {
|
||||||
unsigned char *ptr = iptcTag->getValue();
|
unsigned char *ptr = iptcTag.getValue();
|
||||||
for (int a = 0; a < iptcTag->getCount(); ++a) {
|
for (int a = 0; a < iptcTag.getCount(); ++a) {
|
||||||
unsigned char cc;
|
unsigned char cc;
|
||||||
cc = ptr[3];
|
cc = ptr[3];
|
||||||
ptr[3] = ptr[0];
|
ptr[3] = ptr[0];
|
||||||
@@ -1459,7 +1459,7 @@ int ImageIO::saveTIFF (Glib::ustring fname, int bps, bool uncompressed)
|
|||||||
ptr += 4;
|
ptr += 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TIFFSetField (out, TIFFTAG_RICHTIFFIPTC, iptcTag->getCount(), (long*)iptcTag->getValue());
|
TIFFSetField (out, TIFFTAG_RICHTIFFIPTC, iptcTag.getCount(), (long*)iptcTag.getValue());
|
||||||
iptc_data_free_buf (iptc, iptcdata);
|
iptc_data_free_buf (iptc, iptcdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user