diff options
| author | Carl Hetherington <cth@carlh.net> | 2018-07-09 00:42:15 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2018-07-09 00:42:15 +0100 |
| commit | 34be688550e3acdd99c3ca612e7e4696710f3438 (patch) | |
| tree | ee8df8a736f797bdede41578a7d72d2ebd1682d6 /src | |
| parent | 85bd14f4e7dcbfb2005969575788dbfb303bf846 (diff) | |
Check return value of fread().
Diffstat (limited to 'src')
| -rw-r--r-- | src/mono_picture_frame.cc | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/mono_picture_frame.cc b/src/mono_picture_frame.cc index 7ac807cb..9af34c48 100644 --- a/src/mono_picture_frame.cc +++ b/src/mono_picture_frame.cc @@ -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); |
