/* now we can go ahead and just read the whole image */
- fread(image_data, 1L, rowbytes*height, saved_infile);
-
+ if (fread(image_data, 1L, rowbytes*height, saved_infile) <
+ rowbytes*height) {
+ free (image_data);
+ image_data = NULL;
+ return NULL;
+ }
return image_data;
}