Skip to content

Commit

Permalink
Always copy the JPEG segment size
Browse files Browse the repository at this point in the history
(cherry picked from commit 2469369)
  • Loading branch information
kmilos authored and mergify[bot] committed Jun 18, 2024
1 parent 9a7b9b5 commit 92cd12e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/jpgimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,9 @@ void JpegBase::printStructure(std::ostream& out, PrintStructureOption option, si
} else if (bPrint) {
const size_t start = 2;
const size_t end = size > 34 ? 34 : size;
out << "| " << Internal::binaryToString(makeSlice(buf, start, end));
out << "| ";
if (start < end)
out << Internal::binaryToString(makeSlice(buf, start, end));
if (signature == iccId_) {
// extract the chunk information from the buffer
//
Expand Down Expand Up @@ -601,9 +603,11 @@ DataBuf JpegBase::readNextSegment(byte marker) {

// Read the rest of the segment if not empty.
DataBuf buf(size);
if (size > 2) {
io_->readOrThrow(buf.data(2), size - 2, ErrorCode::kerFailedToReadImageData);
if (size > 0) {
std::copy(sizebuf.begin(), sizebuf.end(), buf.begin());
if (size > 2) {
io_->readOrThrow(buf.data(2), size - 2, ErrorCode::kerFailedToReadImageData);
}
}
return buf;
}
Expand Down

0 comments on commit 92cd12e

Please sign in to comment.