diff --git a/src/jpgimage.cpp b/src/jpgimage.cpp index 13e59471eb..260d2fbf02 100644 --- a/src/jpgimage.cpp +++ b/src/jpgimage.cpp @@ -182,6 +182,7 @@ DataBuf Photoshop::setIptcIrb(const byte* pPsData, size_t sizePsData, const Iptc // Write existing stuff after record, // skip the current and all remaining IPTC blocks size_t pos = sizeFront; + enforce(pos <= sizePsData, ErrorCode::kerCorruptedMetadata); while (0 == Photoshop::locateIptcIrb(pPsData + pos, sizePsData - pos, &record, &sizeHdr, &sizeIptc)) { const auto newPos = static_cast(record - pPsData); // Copy data up to the IPTC IRB