Always copy the JPEG segment size

main
Miloš Komarčević 1 year ago committed by Miloš Komarčević
parent 9999608d34
commit 24693697b6

@ -454,7 +454,9 @@ void JpegBase::printStructure(std::ostream& out, PrintStructureOption option, si
} else if (bPrint) { } else if (bPrint) {
const size_t start = 2; const size_t start = 2;
const size_t end = size > 34 ? 34 : size; 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_) { if (signature == iccId_) {
// extract the chunk information from the buffer // extract the chunk information from the buffer
// //
@ -601,9 +603,11 @@ DataBuf JpegBase::readNextSegment(byte marker) {
// Read the rest of the segment if not empty. // Read the rest of the segment if not empty.
DataBuf buf(size); DataBuf buf(size);
if (size > 2) { if (size > 0) {
io_->readOrThrow(buf.data(2), size - 2, ErrorCode::kerFailedToReadImageData);
std::copy(sizebuf.begin(), sizebuf.end(), buf.begin()); std::copy(sizebuf.begin(), sizebuf.end(), buf.begin());
if (size > 2) {
io_->readOrThrow(buf.data(2), size - 2, ErrorCode::kerFailedToReadImageData);
}
} }
return buf; return buf;
} }

Loading…
Cancel
Save