Fix coverity issues
This commit is contained in:
@@ -1136,15 +1136,21 @@ public:
|
||||
void readData (FILE *f)
|
||||
{
|
||||
for (int i = 0; i < height; i++) {
|
||||
fread (r(i), sizeof(T), width, f);
|
||||
if (fread(r(i), sizeof(T), width, f) < width * sizeof(T)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < height; i++) {
|
||||
fread (g(i), sizeof(T), width, f);
|
||||
if (fread(g(i), sizeof(T), width, f) < width * sizeof(T)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < height; i++) {
|
||||
fread (b(i), sizeof(T), width, f);
|
||||
if (fread(b(i), sizeof(T), width, f) < width * sizeof(T)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1712,7 +1718,9 @@ public:
|
||||
void readData (FILE *f)
|
||||
{
|
||||
for (int i = 0; i < height; i++) {
|
||||
fread (r(i), sizeof(T), 3 * width, f);
|
||||
if (fread(r(i), sizeof(T), 3 * width, f) < 3 * width * sizeof(T)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1949,11 +1949,18 @@ bool Thumbnail::readImage (const Glib::ustring& fname)
|
||||
imgType[strlen(imgType) - 1] = '\0'; // imgType has a \n trailing character, so we overwrite it by the \0 char
|
||||
|
||||
guint32 width, height;
|
||||
fread (&width, 1, sizeof (guint32), f);
|
||||
fread (&height, 1, sizeof (guint32), f);
|
||||
|
||||
if (fread(&width, 1, sizeof(guint32), f) < sizeof(guint32)) {
|
||||
width = 0;
|
||||
}
|
||||
|
||||
if (fread(&height, 1, sizeof(guint32), f) < sizeof(guint32)) {
|
||||
height = 0;
|
||||
}
|
||||
|
||||
bool success = false;
|
||||
|
||||
if (std::min(width , height) > 0) {
|
||||
if (!strcmp(imgType, sImage8)) {
|
||||
Image8 *image = new Image8(width, height);
|
||||
image->readData(f);
|
||||
@@ -1972,7 +1979,7 @@ bool Thumbnail::readImage (const Glib::ustring& fname)
|
||||
} else {
|
||||
printf ("readImage: Unsupported image type \"%s\"!\n", imgType);
|
||||
}
|
||||
|
||||
}
|
||||
fclose(f);
|
||||
return success;
|
||||
}
|
||||
@@ -2229,8 +2236,13 @@ bool Thumbnail::readAEHistogram (const Glib::ustring& fname)
|
||||
aeHistogram.reset();
|
||||
} else {
|
||||
aeHistogram(65536 >> aeHistCompression);
|
||||
fread (&aeHistogram[0], 1, (65536 >> aeHistCompression)*sizeof (aeHistogram[0]), f);
|
||||
const size_t histoBytes = (65536 >> aeHistCompression) * sizeof(aeHistogram[0]);
|
||||
const int bytesRead = fread(&aeHistogram[0], 1, histoBytes, f);
|
||||
fclose (f);
|
||||
if (bytesRead != histoBytes) {
|
||||
aeHistogram.reset();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user