Check return value of fread().
authorCarl Hetherington <cth@carlh.net>
Sun, 8 Jul 2018 23:42:15 +0000 (00:42 +0100)
committerCarl Hetherington <cth@carlh.net>
Sun, 8 Jul 2018 23:42:15 +0000 (00:42 +0100)
src/mono_picture_frame.cc

index 7ac807cba27029c013ca0d00e864e1172a80dc02..9af34c486fda5ffe0d41dd0adef825ebde2c68a6 100644 (file)
@@ -63,7 +63,11 @@ MonoPictureFrame::MonoPictureFrame (boost::filesystem::path path)
                boost::throw_exception (FileError ("could not open JPEG2000 file", path, errno));
        }
 
-       fread (j2k_data(), 1, size, f);
+       size_t n = fread (j2k_data(), 1, size, f);
+       if (n != size) {
+               boost::throw_exception (FileError ("could not read from JPEG2000 file", path, errno));
+       }
+
        fclose (f);
 
        _buffer->Size (size);