From: Carl Hetherington Date: Thu, 16 Apr 2015 08:56:12 +0000 (+0100) Subject: A few missing checks on the return value of fopen_boost. X-Git-Tag: v2.0.48~154 X-Git-Url: https://main.carlh.net/gitweb/?a=commitdiff_plain;h=91bd51ff82e99113860570b519459303802bd98f;p=dcpomatic.git A few missing checks on the return value of fopen_boost. --- diff --git a/src/lib/audio_analysis.cc b/src/lib/audio_analysis.cc index 597c04a22..19a0d876e 100644 --- a/src/lib/audio_analysis.cc +++ b/src/lib/audio_analysis.cc @@ -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 >::iterator i = _data.begin(); i != _data.end(); ++i) { diff --git a/src/lib/encoded_data.cc b/src/lib/encoded_data.cc index 1b1926017..0e8ffd6b5 100644 --- a/src/lib/encoded_data.cc +++ b/src/lib/encoded_data.cc @@ -95,6 +95,9 @@ EncodedData::write_info (shared_ptr 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); }