#511: Changed more throw Error(15) to warnings.

This commit is contained in:
Andreas Huggel 2007-06-14 13:49:55 +00:00
parent 97785b2897
commit 7ba91c5c8f

View File

@ -214,6 +214,8 @@ namespace Exiv2 {
void JpegBase::readMetadata()
{
int rc = 0; // Todo: this should be the return value
if (io_->open() != 0) throw Error(9, io_->path(), strError());
IoCloser closer(*io_);
// Ensure that this is the correct image type
@ -238,7 +240,10 @@ namespace Exiv2 {
uint16_t size = getUShort(buf.pData_, bigEndian);
if (marker == app1_ && memcmp(buf.pData_ + 2, exifId_, 6) == 0) {
if (size < 8) throw Error(15);
if (size < 8) {
rc = 1;
break;
}
// Seek to beginning and read the Exif data
io_->seek(8-bufRead, BasicIo::cur);
long sizeExifData = size - 8;
@ -253,8 +258,12 @@ namespace Exiv2 {
}
--search;
}
else if (marker == app13_ && memcmp(buf.pData_ + 2, Photoshop::ps3Id_, 14) == 0) {
if (size < 16) throw Error(15);
else if ( marker == app13_
&& memcmp(buf.pData_ + 2, Photoshop::ps3Id_, 14) == 0) {
if (size < 16) {
rc = 2;
break;
}
// Read the rest of the APP13 segment
// needed if bufMinSize!=16: io_->seek(16-bufRead, BasicIo::cur);
DataBuf psData(size - 16);
@ -279,7 +288,10 @@ namespace Exiv2 {
}
else if (marker == com_ && comment_.empty())
{
if (size < 2) throw Error(15);
if (size < 2) {
rc = 3;
break;
}
// Jpegs can have multiple comments, but for now only read
// the first one (most jpegs only have one anyway). Comments
// are simple single byte ISO-8859-1 strings.
@ -295,18 +307,24 @@ namespace Exiv2 {
--search;
}
else {
if (size < 2) throw Error(15);
if (size < 2) {
rc = 4;
break;
}
// Skip the remainder of the unknown segment
if (io_->seek(size-bufRead, BasicIo::cur)) throw Error(15);
if (io_->seek(size-bufRead, BasicIo::cur)) throw Error(14);
}
// Read the beginning of the next segment
marker = advanceToMarker();
if (marker < 0) {
#ifndef SUPPRESS_WARNINGS
std::cerr << "Warning: JPEG format error.\n";
#endif
rc = 5;
break;
}
} // while there are segments to process
if (rc != 0) {
#ifndef SUPPRESS_WARNINGS
std::cerr << "Warning: JPEG format error, rc = " << rc << "\n";
#endif
}
} // JpegBase::readMetadata