Merge master; fix destruction of Server; some test cleanups.
[dcpomatic.git] / src / lib / audio_analysis.cc
index 1488f89fcfdfb6f2ac32aaed158e36e1a9eb589d..98d092726c9487f8152a97b6965bd4ff3219df4e 100644 (file)
@@ -93,10 +93,21 @@ AudioAnalysis::AudioAnalysis (boost::filesystem::path filename)
        for (int i = 0; i < channels; ++i) {
                int points;
                fscanf (f, "%d", &points);
+               if (feof (f)) {
+                       fclose (f);
+                       return;
+               }
+               
                for (int j = 0; j < points; ++j) {
                        _data[i].push_back (AudioPoint (f));
+                       if (feof (f)) {
+                               fclose (f);
+                               return;
+                       }
                }
        }
+
+       fclose (f);
 }
 
 void