Skip to content

Commit

Permalink
Always copy the JPEG segment size
Browse files Browse the repository at this point in the history
  • Loading branch information
kmilos committed Jun 17, 2024
1 parent 7bc748f commit c351cce
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 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,9 @@ DataBuf JpegBase::readNextSegment(byte marker) {

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

0 comments on commit c351cce

Please sign in to comment.