Add new LanguageTag class.
[libdcp.git] / src / mono_picture_frame.cc
index 7ac807cba27029c013ca0d00e864e1172a80dc02..d9a89fe12ddad8c77d9f2b6c5901999cf98c11d2 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);
@@ -82,7 +86,7 @@ MonoPictureFrame::MonoPictureFrame (ASDCP::JP2K::MXFReader* reader, int n, share
        ASDCP::Result_t const r = reader->ReadFrame (n, *_buffer, c->context(), c->hmac());
 
        if (ASDCP_FAILURE (r)) {
-               boost::throw_exception (DCPReadError (String::compose ("could not read video frame %1 (%2)", n, static_cast<int>(r))));
+               boost::throw_exception (ReadError (String::compose ("could not read video frame %1 (%2)", n, static_cast<int>(r))));
        }
 }