A few missing checks on the return value of fopen_boost.
authorCarl Hetherington <cth@carlh.net>
Thu, 16 Apr 2015 08:56:12 +0000 (09:56 +0100)
committerCarl Hetherington <cth@carlh.net>
Thu, 16 Apr 2015 08:56:12 +0000 (09:56 +0100)
src/lib/audio_analysis.cc
src/lib/encoded_data.cc

index 597c04a222cd278ebfd95ccab5b54a2bc246c7d7..19a0d876ebc75ab962de69a5408ef42abaa640a0 100644 (file)
@@ -90,6 +90,9 @@ AudioAnalysis::AudioAnalysis (int channels)
 AudioAnalysis::AudioAnalysis (boost::filesystem::path filename)
 {
        FILE* f = fopen_boost (filename, "r");
+       if (!f) {
+               throw OpenFileError (filename);
+       }
 
        int channels = 0;
        fscanf (f, "%d", &channels);
@@ -149,6 +152,9 @@ AudioAnalysis::write (boost::filesystem::path filename)
        tmp.replace_extension (".tmp");
 
        FILE* f = fopen_boost (tmp, "w");
+       if (!f) {
+               throw OpenFileError (tmp);
+       }
 
        fprintf (f, "%ld\n", _data.size ());
        for (vector<vector<AudioPoint> >::iterator i = _data.begin(); i != _data.end(); ++i) {
index 1b1926017993c5da335e6cada7211394c47b86ac..0e8ffd6b5cc088c17fc323c6a807c338263dcc57 100644 (file)
@@ -95,6 +95,9 @@ EncodedData::write_info (shared_ptr<const Film> film, int frame, Eyes eyes, dcp:
 {
        boost::filesystem::path const info = film->info_path (frame, eyes);
        FILE* h = fopen_boost (info, "w");
+       if (!h) {
+               throw OpenFileError (info);
+       }
        fin.write (h);
        fclose (h);
 }