Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Unified Diff: media/base/video_frame.cc

Issue 383893002: Zero initialize the first allocation of a VideoFrame. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | media/base/video_frame_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/video_frame.cc
diff --git a/media/base/video_frame.cc b/media/base/video_frame.cc
index 423c9b1c3f1c2ee392675c8fe46c86fbfcec8e81..74e6cae08d76d9c764a9d5590464edf35c17788a 100644
--- a/media/base/video_frame.cc
+++ b/media/base/video_frame.cc
@@ -618,10 +618,13 @@ void VideoFrame::AllocateYUV() {
// overreads by one line in some cases, see libavcodec/utils.c:
// avcodec_align_dimensions2() and libavcodec/x86/h264_chromamc.asm:
// put_h264_chroma_mc4_ssse3().
+ const size_t data_size =
+ y_bytes + (uv_bytes * 2 + uv_stride) + a_bytes + kFrameSizePadding;
uint8* data = reinterpret_cast<uint8*>(
- base::AlignedAlloc(
- y_bytes + (uv_bytes * 2 + uv_stride) + a_bytes + kFrameSizePadding,
- kFrameAddressAlignment));
+ base::AlignedAlloc(data_size, kFrameAddressAlignment));
+ // FFmpeg expects the initialize allocation to be zero-initialized. Failure
+ // to do so can lead to unitialized value usage. See http://crbug.com/390941
+ memset(data, 0, data_size);
no_longer_needed_cb_ = base::Bind(&ReleaseData, data);
COMPILE_ASSERT(0 == VideoFrame::kYPlane, y_plane_data_must_be_index_0);
data_[VideoFrame::kYPlane] = data;
« no previous file with comments | « no previous file | media/base/video_frame_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698