Fix some coverity issues

This commit is contained in:
heckflosse
2018-11-19 21:49:51 +01:00
parent 4eafdbf248
commit c9044485a6
4 changed files with 25 additions and 17 deletions

View File

@@ -931,7 +931,12 @@ std::shared_ptr<rtengine::LCPProfile> rtengine::LCPStore::getProfile(const Glib:
std::shared_ptr<LCPProfile> res;
if (!cache.get(filename, res)) {
res.reset(new LCPProfile(filename));
try {
res.reset(new LCPProfile(filename));
} catch (...) {
return nullptr;
}
cache.set(filename, res);
}

View File

@@ -479,13 +479,13 @@ int RawImage::loadRaw (bool loadData, unsigned int imageNum, bool closeFile, Pro
iwidth = width;
if (filters || colors == 1) {
raw_image = (ushort *) calloc ((raw_height + 7) * raw_width, 2);
raw_image = (ushort *) calloc ((static_cast<unsigned int>(raw_height) + 7u) * static_cast<unsigned int>(raw_width), 2);
merror (raw_image, "main()");
}
// dcraw needs this global variable to hold pixel data
image = (dcrawImage_t)calloc (height * width * sizeof * image + meta_length, 1);
meta_data = (char *) (image + height * width);
image = (dcrawImage_t)calloc (static_cast<unsigned int>(height) * static_cast<unsigned int>(width) * sizeof * image + meta_length, 1);
meta_data = (char *) (image + static_cast<unsigned int>(height) * static_cast<unsigned int>(width));
if(!image) {
return 200;
@@ -673,7 +673,7 @@ int RawImage::loadRaw (bool loadData, unsigned int imageNum, bool closeFile, Pro
return 0;
}
float** RawImage::compress_image(int frameNum, bool freeImage)
float** RawImage::compress_image(unsigned int frameNum, bool freeImage)
{
if( !image ) {
return nullptr;
@@ -682,7 +682,7 @@ float** RawImage::compress_image(int frameNum, bool freeImage)
if (isBayer() || isXtrans()) {
if (!allocation) {
// shift the beginning of all frames but the first by 32 floats to avoid cache miss conflicts on CPUs which have <= 4-way associative L1-Cache
allocation = new float[height * width + frameNum * 32];
allocation = new float[static_cast<unsigned int>(height) * static_cast<unsigned int>(width) + frameNum * 32u];
data = new float*[height];
for (int i = 0; i < height; i++) {

View File

@@ -121,7 +121,7 @@ public:
{
return image;
}
float** compress_image(int frameNum, bool freeImage = true); // revert to compressed pixels format and release image data
float** compress_image(unsigned int frameNum, bool freeImage = true); // revert to compressed pixels format and release image data
float** data; // holds pixel values, data[i][j] corresponds to the ith row and jth column
unsigned prefilters; // original filters saved ( used for 4 color processing )
unsigned int getFrameCount() const { return is_raw; }