diff --git a/samples/metacopy.cpp b/samples/metacopy.cpp index a43b20f5..5c931dda 100644 --- a/samples/metacopy.cpp +++ b/samples/metacopy.cpp @@ -59,7 +59,9 @@ try { Exiv2::Image::UniquePtr writeImg = Exiv2::ImageFactory::open(params.write_); assert(writeImg.get() != 0); - if (params.preserve_) writeImg->readMetadata(); + if (params.preserve_) { + writeImg->readMetadata(); + } if (params.iptc_) { writeImg->setIptcData(readImg->iptcData()); } diff --git a/src/iptc.cpp b/src/iptc.cpp index 776ef9ca..b3874a46 100644 --- a/src/iptc.cpp +++ b/src/iptc.cpp @@ -505,6 +505,7 @@ namespace Exiv2 { DataBuf IptcParser::encode(const IptcData& iptcData) { + /// \todo if iptcData.size() == 0 return early DataBuf buf(iptcData.size()); byte *pWrite = buf.data(); diff --git a/src/jpgimage.cpp b/src/jpgimage.cpp index d1fed0c7..eaf186e2 100644 --- a/src/jpgimage.cpp +++ b/src/jpgimage.cpp @@ -1013,6 +1013,7 @@ namespace Exiv2 { // potential to change segment ordering (which is allowed). // Segments are erased if there is no assigned metadata. while (marker != sos_ && search > 0) { + /// \todo same block than above ... reuse!!! // 2-byte buffer for reading the size. byte sizebuf[2]; uint16_t size = 0; @@ -1147,10 +1148,10 @@ namespace Exiv2 { static_cast(psBlob.size()), iptcData_); const long maxChunkSize = 0xffff - 16; const byte* chunkStart = newPsData.c_data(); - const byte* chunkEnd = newPsData.c_data(newPsData.size()-1); + const byte* chunkEnd = newPsData.size() == 0 ? nullptr : newPsData.c_data(newPsData.size()-1); while (chunkStart < chunkEnd) { // Determine size of next chunk - long chunkSize = static_cast(chunkEnd - chunkStart); + long chunkSize = static_cast(chunkEnd + 1 - chunkStart); if (chunkSize > maxChunkSize) { chunkSize = maxChunkSize; // Don't break at a valid IRB boundary