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

Unified Diff: media/cdm/simple_cdm_buffer.cc

Issue 1802183002: Convert CreateCdmBuffer() to use size_t for |capacity| (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
Index: media/cdm/simple_cdm_buffer.cc
diff --git a/media/cdm/simple_cdm_buffer.cc b/media/cdm/simple_cdm_buffer.cc
index c5f3b8bbf96d0e88d159cb81d49e299a1ad148f8..6e0074e1ac2e5a3dd80719105c9b0293ac940d57 100644
--- a/media/cdm/simple_cdm_buffer.cc
+++ b/media/cdm/simple_cdm_buffer.cc
@@ -4,14 +4,23 @@
#include "media/cdm/simple_cdm_buffer.h"
+#include <limits>
+
#include "base/logging.h"
+#include "base/numerics/safe_conversions.h"
namespace media {
// static
-SimpleCdmBuffer* SimpleCdmBuffer::Create(uint32_t capacity) {
+SimpleCdmBuffer* SimpleCdmBuffer::Create(size_t capacity) {
DCHECK(capacity);
- return new SimpleCdmBuffer(capacity);
+
+ // cdm::Buffer interface limits capacity to uint32. Requests bigger than
+ // uint32_max will fail.
+ if (capacity > static_cast<size_t>(std::numeric_limits<uint32_t>::max()))
+ return nullptr;
xhwang 2016/03/15 06:17:22 This should really never happen since the caller o
jrummell 2016/03/15 18:49:42 Done.
+
+ return new SimpleCdmBuffer(base::checked_cast<uint32_t>(capacity));
}
SimpleCdmBuffer::SimpleCdmBuffer(uint32_t capacity)

Powered by Google App Engine
This is Rietveld 408576698