Chromium Code Reviews| 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) |