Commit eb2367e5 authored by Antoine Labour's avatar Antoine Labour Committed by Commit Bot

Properly check handle type in GpuMemoryBufferFactory*

Calling code (CommandBufferStub via GpuChannel) doesn't check that the
GMB handle type corresponds to the correct platform-specific handle
(indeed it doesn't have a way to). So check in the
GpuMemoryBufferFactory* classes and fail if the handle type is invalid.

Bug: 870116
Change-Id: I78b574439350bee3dccda569e53eae7f74c7d0a7
Reviewed-on: https://chromium-review.googlesource.com/c/1316168Reviewed-by: default avatarVictor Miura <vmiura@chromium.org>
Commit-Queue: Antoine Labour <piman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605127}
parent 7bc5cee8
......@@ -66,9 +66,8 @@ GpuMemoryBufferFactoryAndroidHardwareBuffer::CreateImageForGpuMemoryBuffer(
gfx::BufferFormat format,
int client_id,
SurfaceHandle surface_handle) {
// We should only end up in this code path if the memory buffer has a valid
// AHardwareBuffer.
DCHECK_EQ(handle.type, gfx::ANDROID_HARDWARE_BUFFER);
if (handle.type != gfx::ANDROID_HARDWARE_BUFFER)
return nullptr;
base::android::ScopedHardwareBufferHandle& buffer =
handle.android_hardware_buffer;
......
......@@ -111,9 +111,11 @@ GpuMemoryBufferFactoryIOSurface::CreateImageForGpuMemoryBuffer(
gfx::BufferFormat format,
int client_id,
SurfaceHandle surface_handle) {
if (handle.type != gfx::IO_SURFACE_BUFFER)
return nullptr;
base::AutoLock lock(io_surfaces_lock_);
DCHECK_EQ(handle.type, gfx::IO_SURFACE_BUFFER);
IOSurfaceMapKey key(handle.id, client_id);
IOSurfaceMap::iterator it = io_surfaces_.find(key);
if (it == io_surfaces_.end()) {
......
......@@ -85,7 +85,8 @@ GpuMemoryBufferFactoryNativePixmap::CreateImageForGpuMemoryBuffer(
gfx::BufferFormat format,
int client_id,
SurfaceHandle surface_handle) {
DCHECK_EQ(handle.type, gfx::NATIVE_PIXMAP);
if (handle.type != gfx::NATIVE_PIXMAP)
return nullptr;
scoped_refptr<gfx::NativePixmap> pixmap;
......
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