From c47f0099eee08e8b6731a359563ba09dfe453ded Mon Sep 17 00:00:00 2001 From: Tommi Date: Thu, 26 May 2016 22:55:35 +0200 Subject: [PATCH] Reland of Adding a some checks and switching out a few assert for RTC_[D]CHECK. (patchset #1 id:1 of https://codereview.webrtc.org/2018553002/ ) Adding a some checks and switching out a few assert for RTC_[D]CHECK. These changes are around use of AudioFrame.data_ to help us catch issues earlier since assert() is left out in release builds, including builds with DCHECK enabled. I've also added a few full-on CHECKs to avoid reading past buffer boundaries or continuing on in a failed state. TBR=kjellander@webrtc.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Committed: https://crrev.com/60c4e0ae8f124f08372645a95042f4a1246d7aa3 Cr-Commit-Position: refs/heads/master@{#12925} Committed: https://crrev.com/5771beb265129082d31736259b7dc6ca037cff4d Cr-Commit-Position: refs/heads/master@{#12926} Committed: https://crrev.com/54e1c6a500e390e543bce7b78fae65eb9bb14ab6 Cr-Commit-Position: refs/heads/master@{#12927} Committed: https://crrev.com/f9d2fe983fe196373850c55acd3dc3824add480e Cr-Commit-Position: refs/heads/master@{#12928} Committed: https://chromium.googlesource.com/external/webrtc/+/f4fc0ff6f98695eaee527762c27824938d57c442 Review URL: https://codereview.webrtc.org/2014973002 . Cr-Commit-Position: refs/heads/master@{#12930} --- webrtc/common_audio/resampler/push_resampler.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/webrtc/common_audio/resampler/push_resampler.cc b/webrtc/common_audio/resampler/push_resampler.cc index 03d481cd06..9b8f38b140 100644 --- a/webrtc/common_audio/resampler/push_resampler.cc +++ b/webrtc/common_audio/resampler/push_resampler.cc @@ -31,7 +31,10 @@ void CheckValidInitParams(int src_sample_rate_hz, int dst_sample_rate_hz, RTC_DCHECK_LE(num_channels, 2u); } -void CheckExpectedBufferSizes(size_t num_channels, int src_sample_rate, +void CheckExpectedBufferSizes(size_t src_length, + size_t dst_capacity, + size_t num_channels, + int src_sample_rate, int dst_sample_rate) { const size_t src_size_10ms = src_sample_rate * num_channels / 100; const size_t dst_size_10ms = dst_sample_rate * num_channels / 100; @@ -94,8 +97,8 @@ int PushResampler::InitializeIfNeeded(int src_sample_rate_hz, template int PushResampler::Resample(const T* src, size_t src_length, T* dst, size_t dst_capacity) { - CheckExpectedBufferSizes(num_channels_, src_sample_rate_hz_, - dst_sample_rate_hz_) + CheckExpectedBufferSizes(src_length, dst_capacity, num_channels_, + src_sample_rate_hz_, dst_sample_rate_hz_); if (src_sample_rate_hz_ == dst_sample_rate_hz_) { // The old resampler provides this memcpy facility in the case of matching