diff options
author | andrew@webrtc.org <andrew@webrtc.org> | 2014-09-08 23:11:44 +0000 |
---|---|---|
committer | andrew@webrtc.org <andrew@webrtc.org> | 2014-09-08 23:11:44 +0000 |
commit | 641bda6f9c896726887f52bfc1f5a2e0799e0d94 (patch) | |
tree | c843e451057a97df0a165694c417132dbdb0518a /webrtc/modules/audio_processing/common.h | |
parent | 8b0b21161abdcdc2f2528aadf25f1f8f5c99e8b2 (diff) | |
download | webrtc-641bda6f9c896726887f52bfc1f5a2e0799e0d94.tar.gz |
Initialize ChannelBuffer's memory to avoid uninitialized reads.
Removed the zero out memset in this change:
https://review.webrtc.org/24469004/
assuming it was unneeded. Dr. Memory taught me that assupmtion was
invalid. linux_memcheck try runs might have caught this, if they
weren't flaking out on unrelated stuff.
TBR=claguna@google.com
Review URL: https://webrtc-codereview.appspot.com/28429004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7113 4adac7df-926f-26a2-2b94-8c16560cd09d
Diffstat (limited to 'webrtc/modules/audio_processing/common.h')
-rw-r--r-- | webrtc/modules/audio_processing/common.h | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/webrtc/modules/audio_processing/common.h b/webrtc/modules/audio_processing/common.h index c1bae896ce..98c624127c 100644 --- a/webrtc/modules/audio_processing/common.h +++ b/webrtc/modules/audio_processing/common.h @@ -43,7 +43,7 @@ class ChannelBuffer { channels_(new T*[num_channels]), samples_per_channel_(samples_per_channel), num_channels_(num_channels) { - SetChannelPtrs(); + Initialize(); } ChannelBuffer(const T* data, int samples_per_channel, int num_channels) @@ -51,7 +51,7 @@ class ChannelBuffer { channels_(new T*[num_channels]), samples_per_channel_(samples_per_channel), num_channels_(num_channels) { - SetChannelPtrs(); + Initialize(); memcpy(data_.get(), data, length() * sizeof(T)); } @@ -61,7 +61,7 @@ class ChannelBuffer { channels_(new T*[num_channels]), samples_per_channel_(samples_per_channel), num_channels_(num_channels) { - SetChannelPtrs(); + Initialize(); for (int i = 0; i < num_channels_; ++i) CopyFrom(channels[i], i); } @@ -94,7 +94,8 @@ class ChannelBuffer { int length() const { return samples_per_channel_ * num_channels_; } private: - void SetChannelPtrs() { + void Initialize() { + memset(data_.get(), 0, sizeof(T) * length()); for (int i = 0; i < num_channels_; ++i) channels_[i] = &data_[i * samples_per_channel_]; } |