Do not access the first element of an empty vector.
This commit is contained in:
parent
a05687e159
commit
6f5032db37
@ -164,7 +164,7 @@ namespace Exiv2 {
|
||||
// Write new buffer to file
|
||||
BasicIo::AutoPtr tempIo(io_->temporary()); // may throw
|
||||
assert(tempIo.get() != 0);
|
||||
tempIo->write(&blob[0], static_cast<long>(blob.size()));
|
||||
tempIo->write((blob.size() > 0 ? &blob[0] : 0), static_cast<long>(blob.size()));
|
||||
io_->close();
|
||||
io_->transfer(*tempIo); // may throw
|
||||
|
||||
|
||||
@ -679,7 +679,7 @@ namespace {
|
||||
const Exiv2::IptcData emptyIptc;
|
||||
const Exiv2::XmpData emptyXmp;
|
||||
Exiv2::TiffParser::encode(blob, 0, 0, Exiv2::littleEndian, thumb, emptyIptc, emptyXmp);
|
||||
return Exiv2::DataBuf(&blob[0], static_cast<long>(blob.size()));
|
||||
return Exiv2::DataBuf((blob.size() > 0 ? &blob[0] : 0), static_cast<long>(blob.size()));
|
||||
}
|
||||
|
||||
const char* JpegThumbnail::mimeType() const
|
||||
|
||||
@ -616,9 +616,8 @@ namespace Exiv2 {
|
||||
const byte* pExifData = rawExif.pData_;
|
||||
uint32_t exifSize = rawExif.size_;
|
||||
if (wm == wmIntrusive) {
|
||||
pExifData = blob.size() > 0 ? &blob[0] : 0;
|
||||
exifSize = static_cast<uint32_t>(blob.size());
|
||||
// Extra check to prevent MSVC debug assertion
|
||||
if (exifSize > 0) pExifData = &blob[0];
|
||||
}
|
||||
if (exifSize > 0) {
|
||||
// Write APP1 marker, size of APP1 field, Exif id and Exif data
|
||||
|
||||
@ -639,7 +639,7 @@ namespace {
|
||||
const IptcData emptyIptc;
|
||||
const XmpData emptyXmp;
|
||||
TiffParser::encode(blob, 0, 0, Exiv2::littleEndian, preview, emptyIptc, emptyXmp);
|
||||
return DataBuf(&blob[0], static_cast<long>(blob.size()));
|
||||
return DataBuf((blob.size() > 0 ? &blob[0] : 0), static_cast<long>(blob.size()));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@ -177,7 +177,7 @@ namespace Exiv2 {
|
||||
}
|
||||
else {
|
||||
// Size of the buffer changed, write from blob
|
||||
tempIo->write(&blob[0], static_cast<long>(blob.size()));
|
||||
tempIo->write((blob.size() > 0 ? &blob[0] : 0), static_cast<long>(blob.size()));
|
||||
}
|
||||
io_->close();
|
||||
io_->transfer(*tempIo); // may throw
|
||||
|
||||
Loading…
Reference in New Issue
Block a user