From c4e514cff8fa65906918664963447df7717b0802 Mon Sep 17 00:00:00 2001 From: Mohamed Ali Chebbi Date: Wed, 12 Apr 2023 01:51:38 +0200 Subject: [PATCH] Current master fails with image #2565 --- src/jpgimage.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/jpgimage.cpp b/src/jpgimage.cpp index 5d6cb856..18361439 100644 --- a/src/jpgimage.cpp +++ b/src/jpgimage.cpp @@ -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());