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

Unified Diff: content/browser/device_sensors/data_fetcher_shared_memory_base.cc

Issue 1954753002: device_sensors: make sure to clear the shared memory buffer on each start. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 | content/browser/device_sensors/data_fetcher_shared_memory_base_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/device_sensors/data_fetcher_shared_memory_base.cc
diff --git a/content/browser/device_sensors/data_fetcher_shared_memory_base.cc b/content/browser/device_sensors/data_fetcher_shared_memory_base.cc
index 2689b60e306826fe22defecb94cd254d1d4cd9f1..053807680fd4f211a38492dbfd3e89b54f4da4d4 100644
--- a/content/browser/device_sensors/data_fetcher_shared_memory_base.cc
+++ b/content/browser/device_sensors/data_fetcher_shared_memory_base.cc
@@ -133,6 +133,12 @@ bool DataFetcherSharedMemoryBase::StartFetchingDeviceData(
if (!buffer)
return false;
+ size_t buffer_size = GetConsumerSharedMemoryBufferSize(consumer_type);
+ // buffer size should be strictly positive because buffer is non-zero.
+ DCHECK(buffer_size > 0);
+ // make sure to clear any potentially stale values in the memory buffer.
+ memset(buffer, 0, buffer_size);
+
if (GetType() != FETCHER_TYPE_DEFAULT) {
if (!InitAndStartPollingThreadIfNecessary())
return false;
« no previous file with comments | « no previous file | content/browser/device_sensors/data_fetcher_shared_memory_base_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698