From 287755246a403a7a6e686bc921f59894669e362c Mon Sep 17 00:00:00 2001 From: "henrik.lundin@webrtc.org" Date: Thu, 19 Feb 2015 13:55:36 +0000 Subject: [PATCH] Fix a problem with reading uninitialized memory in ACM When an "empty frame" was produced by ACMGenericCodecWrapper::Encode, the timestamp value was not set. This is now fixed, and the first byte of the bitstream is set to something as well to avoid similar problems. BUG=chromium:459483 R=jmarusic@webrtc.org Review URL: https://webrtc-codereview.appspot.com/34269004 Cr-Commit-Position: refs/heads/master@{#8431} git-svn-id: http://webrtc.googlecode.com/svn/trunk@8431 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../modules/audio_coding/main/acm2/acm_generic_codec.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/webrtc/modules/audio_coding/main/acm2/acm_generic_codec.cc b/webrtc/modules/audio_coding/main/acm2/acm_generic_codec.cc index 5e9930e1c..6dd6f3edd 100644 --- a/webrtc/modules/audio_coding/main/acm2/acm_generic_codec.cc +++ b/webrtc/modules/audio_coding/main/acm2/acm_generic_codec.cc @@ -1224,11 +1224,15 @@ int16_t ACMGenericCodecWrapper::Encode( 2 * MAX_PAYLOAD_SIZE_BYTE, bitstream, encoded_info)); input_.clear(); *bitstream_len_byte = static_cast(encoded_info->encoded_bytes); + *timestamp = encoded_info->encoded_timestamp; if (encoded_info->encoded_bytes == 0) { *encoding_type = kNoEncoding; - return encoded_info->send_even_if_empty ? 1 : 0; + if (encoded_info->send_even_if_empty) { + bitstream[0] = 0; + return 1; + } + return 0; } - *timestamp = encoded_info->encoded_timestamp; int payload_type = encoded_info->payload_type; if (!encoded_info->redundant.empty())