Current master fails with image #2565

This commit is contained in:
Mohamed Ali Chebbi 2023-04-12 01:51:38 +02:00 committed by Rosen Penev
parent 498f4ce273
commit c4e514cff8

View File

@ -152,7 +152,7 @@ void JpegBase::readMetadata() {
const auto [sizebuf, size] = readSegmentSize(marker, *io_);
// Read the rest of the segment.
DataBuf buf(size);
DataBuf buf(size + 1);
/// \todo check if it makes sense to check for size
if (size > 0) {
io_->readOrThrow(buf.data(2), size - 2, ErrorCode::kerFailedToReadImageData);
@ -353,7 +353,7 @@ void JpegBase::printStructure(std::ostream& out, PrintStructureOption option, si
const auto [sizebuf, size] = readSegmentSize(marker, *io_);
// Read the rest of the segment.
DataBuf buf(size);
DataBuf buf(size + 1);
if (size > 0) {
io_->readOrThrow(buf.data(2), size - 2, ErrorCode::kerFailedToReadImageData);
std::copy(sizebuf.begin(), sizebuf.end(), buf.begin());
@ -565,7 +565,7 @@ DataBuf JpegBase::readNextSegment(byte marker) {
const auto [sizebuf, size] = readSegmentSize(marker, *io_);
// Read the rest of the segment.
DataBuf buf(size);
DataBuf buf(size + 1);
if (size > 0) {
io_->readOrThrow(buf.data(2), size - 2, ErrorCode::kerFailedToReadImageData);
std::copy(sizebuf.begin(), sizebuf.end(), buf.begin());