Index: chrome/browser/media/webrtc/webrtc_browsertest_audio.cc |
diff --git a/chrome/browser/media/webrtc/webrtc_browsertest_audio.cc b/chrome/browser/media/webrtc/webrtc_browsertest_audio.cc |
index 3ed59478f354a22a1b6f7fbaa3d52c21cf3b7a2d..041cfa585b3a385946f74861618a78244b65361e 100644 |
--- a/chrome/browser/media/webrtc/webrtc_browsertest_audio.cc |
+++ b/chrome/browser/media/webrtc/webrtc_browsertest_audio.cc |
@@ -27,10 +27,23 @@ std::unique_ptr<char[]> ReadWavFile(const base::FilePath& wav_filename, |
return nullptr; |
} |
- size_t wav_file_length = wav_file.GetLength(); |
+ int64_t wav_file_length64 = wav_file.GetLength(); |
+ if (wav_file_length64 < 0) { |
+ PLOG(ERROR) << "GetLength " << wav_file.GetPlatformFile(); |
+ return nullptr; |
+ } |
+ if (wav_file_length64 > std::numeric_limits<int>::max()) { |
+ LOG(ERROR) << "File is too big: " << wav_filename.value(); |
+ return nullptr; |
+ } |
+ int wav_file_length = static_cast<int>(wav_file_length64); |
+ if (!wav_file_length) { |
+ LOG(ERROR) << "Input file is empty: " << wav_filename.value(); |
+ return nullptr; |
+ } |
std::unique_ptr<char[]> data(new char[wav_file_length]); |
- size_t read_bytes = wav_file.Read(0, data.get(), wav_file_length); |
+ int read_bytes = wav_file.Read(0, data.get(), wav_file_length); |
if (read_bytes != wav_file_length) { |
LOG(ERROR) << "Failed to read all bytes of " << wav_filename.value(); |
return nullptr; |