From cff1efe122330771d5d792aebc25a4f1ec705abc Mon Sep 17 00:00:00 2001 From: Mahesh Date: Sun, 20 Jul 2014 15:45:33 +0000 Subject: [PATCH] Coverity scan fixes CID : 981999 (size overflow warning : typecasted) and 981993( divided by zeor warning : added check beore operation) --- src/jp2image.cpp | 2 +- src/value.hpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/jp2image.cpp b/src/jp2image.cpp index c32e3e42..da2128a3 100644 --- a/src/jp2image.cpp +++ b/src/jp2image.cpp @@ -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); diff --git a/src/value.hpp b/src/value.hpp index 59a72f9f..c3eb459f 100644 --- a/src/value.hpp +++ b/src/value.hpp @@ -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(buf + i, byteOrder)); }