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

Unified Diff: content/browser/renderer_host/media/audio_input_renderer_host.cc

Issue 214343006: Check shared memory size before allocating it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/media/audio_input_renderer_host.cc
diff --git a/content/browser/renderer_host/media/audio_input_renderer_host.cc b/content/browser/renderer_host/media/audio_input_renderer_host.cc
index 67067c7833265caf8574825af805e961781ea880..ca5d0683d209a56a187430639fc1a85b811f2fd4 100644
--- a/content/browser/renderer_host/media/audio_input_renderer_host.cc
+++ b/content/browser/renderer_host/media/audio_input_renderer_host.cc
@@ -7,6 +7,7 @@
#include "base/bind.h"
#include "base/memory/shared_memory.h"
#include "base/metrics/histogram.h"
+#include "base/numerics/safe_math.h"
#include "base/process/process.h"
#include "base/strings/stringprintf.h"
#include "content/browser/media/capture/web_contents_audio_input_stream.h"
@@ -259,8 +260,10 @@ void AudioInputRendererHost::OnCreateStream(
// Create the shared memory and share it with the renderer process
// using a new SyncWriter object.
- if (!entry->shared_memory.CreateAndMapAnonymous(
- segment_size * entry->shared_memory_segment_count)) {
+ base::CheckedNumeric<uint32> size = segment_size;
+ size *= entry->shared_memory_segment_count;
+ if (!size.IsValid() ||
+ !entry->shared_memory.CreateAndMapAnonymous(size.ValueOrDie())) {
// If creation of shared memory failed then send an error message.
SendErrorMessage(stream_id, SHARED_MEMORY_CREATE_FAILED);
return;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698