Commit 9d00ee85 authored by Eugene Zemtsov's avatar Eugene Zemtsov Committed by Commit Bot

[webcodecs] Limit max frame size to 8k

8k is big enough for most practical applications and saves some
of OOMs and crashes of underlying codecs.

Bug: 1127633, 1129359
Change-Id: I619a28dd6cb4eefc38f0328ca179e2684e627826
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2417511
Commit-Queue: Eugene Zemtsov <eugene@chromium.org>
Reviewed-by: default avatarThomas Guilbert <tguilbert@chromium.org>
Cr-Commit-Position: refs/heads/master@{#808216}
parent 366a2194
...@@ -129,16 +129,19 @@ int32_t VideoEncoder::encodeQueueSize() { ...@@ -129,16 +129,19 @@ int32_t VideoEncoder::encodeQueueSize() {
std::unique_ptr<VideoEncoder::ParsedConfig> VideoEncoder::ParseConfig( std::unique_ptr<VideoEncoder::ParsedConfig> VideoEncoder::ParseConfig(
const VideoEncoderConfig* config, const VideoEncoderConfig* config,
ExceptionState& exception_state) { ExceptionState& exception_state) {
constexpr int kMaxSupportedFrameSize = 8000;
auto parsed = std::make_unique<ParsedConfig>(); auto parsed = std::make_unique<ParsedConfig>();
parsed->options.height = config->height(); parsed->options.height = config->height();
if (parsed->options.height == 0) { if (parsed->options.height == 0 ||
parsed->options.height > kMaxSupportedFrameSize) {
exception_state.ThrowTypeError("Invalid height."); exception_state.ThrowTypeError("Invalid height.");
return nullptr; return nullptr;
} }
parsed->options.width = config->width(); parsed->options.width = config->width();
if (parsed->options.width == 0) { if (parsed->options.width == 0 ||
parsed->options.width > kMaxSupportedFrameSize) {
exception_state.ThrowTypeError("Invalid width."); exception_state.ThrowTypeError("Invalid width.");
return nullptr; return nullptr;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment