Skip to content

Commit

Permalink
Fix handle validity check in ChildHistogramFetcherImpl
Browse files Browse the repository at this point in the history
Invalid Mojo shared memory handles can be "successfully" unwrapped to
invalid base shared memory handles. This may be a little weird, but
that API is going away in favor of unwrapping new base shared memory
types anyway.

So rather than changing the API behavior, this fixes the check in
ChildHistogramFetcherImpl so it doesn't attempt to use an invalid
base::SharedMemoryHandle.

Bug: 835837
Change-Id: If6f4fd5086547e671e4d86363ede9513adb2c054
Reviewed-on: https://chromium-review.googlesource.com/1024114
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Commit-Queue: Ken Rockot <rockot@chromium.org>
Cr-Commit-Position: refs/heads/master@{#552763}
  • Loading branch information
krockot authored and Commit Bot committed Apr 23, 2018
1 parent 850001f commit fdd88a6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion content/child/child_histogram_fetcher_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void ChildHistogramFetcherFactoryImpl::CreateFetcher(
const MojoResult result = mojo::UnwrapSharedMemoryHandle(
std::move(buffer_handle), &memory_handle, &memory_size, nullptr);

if (result == MOJO_RESULT_OK) {
if (result == MOJO_RESULT_OK && memory_handle.IsValid()) {
// This message must be received only once. Multiple calls to create a
// global allocator will cause a CHECK() failure.
base::GlobalHistogramAllocator::CreateWithSharedMemoryHandle(memory_handle,
Expand Down

0 comments on commit fdd88a6

Please sign in to comment.