Coverity scan fixes CID : 981999 (size overflow warning : typecasted) and 981993( divided by zeor warning : added check beore operation)

This commit is contained in:
Mahesh 2014-07-20 15:45:33 +00:00
parent d3e0539bac
commit cff1efe122
2 changed files with 3 additions and 2 deletions

View File

@ -317,7 +317,7 @@ namespace Exiv2
std::cout << "Exiv2::Jp2Image::readMetadata: Xmp data found\n";
#endif
rawData.alloc(box.boxLength - (sizeof(box) + sizeof(uuid)));
rawData.alloc(box.boxLength - (u_int32_t)(sizeof(box) + sizeof(uuid)));
bufRead = io_->read(rawData.pData_, rawData.size_);
if (io_->error()) throw Error(14);
if (bufRead != rawData.size_) throw Error(20);

View File

@ -1550,7 +1550,8 @@ namespace Exiv2 {
{
value_.clear();
long ts = TypeInfo::typeSize(typeId());
if (len % ts != 0) len = (len / ts) * ts;
if (ts != 0)
if (len % ts != 0) len = (len / ts) * ts;
for (long i = 0; i < len; i += ts) {
value_.push_back(getValue<T>(buf + i, byteOrder));
}