Index: media/audio/simple_sources.cc |
diff --git a/media/audio/simple_sources.cc b/media/audio/simple_sources.cc |
index 877f9fd5bdac20866823b14574e1c46e03c7e23e..4bc35494a1a1e1bf0d145a350426357173f68bed 100644 |
--- a/media/audio/simple_sources.cc |
+++ b/media/audio/simple_sources.cc |
@@ -49,8 +49,7 @@ static scoped_ptr<uint8[]> ReadWavFile(const base::FilePath& wav_filename, |
return scoped_ptr<uint8[]>(wav_file_data); |
} |
-// Opens |wav_filename|, reads it and loads it as a wav file. This function will |
-// bluntly trigger CHECKs if we can't read the file or if it's malformed. |
+// Opens |wav_filename|, reads it and loads it as a wav file. |
static scoped_ptr<WavAudioHandler> CreateWavAudioHandler( |
const base::FilePath& wav_filename, const uint8* wav_file_data, |
size_t wav_file_length, const AudioParameters& expected_params) { |
@@ -179,8 +178,15 @@ void FileSource::LoadWavFile(const base::FilePath& path_to_wav_file) { |
return; |
} |
+ // Attempt to create a handler with this data. If the data is invalid, return. |
wav_audio_handler_ = CreateWavAudioHandler( |
path_to_wav_file, wav_file_data_.get(), file_length, params_); |
+ if (!wav_audio_handler_->is_valid()) { |
+ LOG(ERROR) << "WAV data could be read but is not valid"; |
+ wav_audio_handler_.reset(); |
+ load_failed_ = true; |
+ return; |
+ } |
// Hook us up so we pull in data from the file into the converter. We need to |
// modify the wav file's audio parameters since we'll be reading small slices |