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

Unified Diff: media/filters/gpu_video_decoder.cc

Issue 11826064: Enforce non-negative BitstreamBuffer id (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Documented the wrapping at 30 bits. Created 7 years, 11 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 | « media/filters/gpu_video_decoder.h ('k') | ppapi/api/dev/pp_video_dev.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/gpu_video_decoder.cc
diff --git a/media/filters/gpu_video_decoder.cc b/media/filters/gpu_video_decoder.cc
index b2e5670336de3485d57b61fb7cb5b1739801c3d3..f36bff05fed050b35205316c9923e89e87405f37 100644
--- a/media/filters/gpu_video_decoder.cc
+++ b/media/filters/gpu_video_decoder.cc
@@ -284,7 +284,9 @@ void GpuVideoDecoder::RequestBufferDecode(
SHMBuffer* shm_buffer = GetSHM(size);
memcpy(shm_buffer->shm->memory(), buffer->GetData(), size);
BitstreamBuffer bitstream_buffer(
- next_bitstream_buffer_id_++, shm_buffer->shm->handle(), size);
+ next_bitstream_buffer_id_, shm_buffer->shm->handle(), size);
+ // Mask against 30 bits, to avoid (undefined) wraparound on signed integer.
+ next_bitstream_buffer_id_ = (next_bitstream_buffer_id_ + 1) & 0x3FFFFFFF;
bool inserted = bitstream_buffers_in_decoder_.insert(std::make_pair(
bitstream_buffer.id(), BufferPair(shm_buffer, buffer))).second;
DCHECK(inserted);
« no previous file with comments | « media/filters/gpu_video_decoder.h ('k') | ppapi/api/dev/pp_video_dev.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698