Commit 1a7ccea6 authored by Oksana Zhuravlova's avatar Oksana Zhuravlova Committed by Commit Bot

[mojo] Check that shared memory is valid before trying to write into it

It's possible for BigBufferView::shared_memory_ to be null if memory
mapping fails. This change adds a check that the mapping is not null
before trying to write there.

Bug: 961256
Change-Id: I72772e07583ab62df5544d419604356071071e94
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1611311Reviewed-by: default avatarKen Rockot <rockot@google.com>
Commit-Queue: Oksana Zhuravlova <oksamyt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#660010}
parent e03b06c2
......@@ -112,9 +112,11 @@ BigBufferView::BigBufferView(base::span<const uint8_t> bytes) {
if (buffer.is_valid()) {
storage_type_ = BigBuffer::StorageType::kSharedMemory;
shared_memory_.emplace(std::move(buffer), bytes.size());
std::copy(bytes.begin(), bytes.end(),
static_cast<uint8_t*>(shared_memory_->buffer_mapping_.get()));
return;
if (shared_memory_->buffer_mapping_) {
std::copy(bytes.begin(), bytes.end(),
static_cast<uint8_t*>(shared_memory_->buffer_mapping_.get()));
return;
}
}
if (bytes.size() > kMaxFallbackInlineBytes) {
......
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