Bug 1268721 - part 2 - Null check first argument to nsContentUtils::GetSurfaceData(). r=jimm, a=ritu

This commit is contained in:
Andrew McCreight 2016-05-12 11:04:00 +02:00
parent 5b6a77c4b8
commit 4bedd9c01c
3 changed files with 21 additions and 13 deletions

View File

@ -7578,6 +7578,9 @@ nsContentUtils::TransferableToIPCTransferable(nsITransferable* aTransferable,
} }
RefPtr<mozilla::gfx::DataSourceSurface> dataSurface = RefPtr<mozilla::gfx::DataSourceSurface> dataSurface =
surface->GetDataSurface(); surface->GetDataSurface();
if (!dataSurface) {
continue;
}
size_t length; size_t length;
int32_t stride; int32_t stride;
mozilla::UniquePtr<char[]> surfaceData = mozilla::UniquePtr<char[]> surfaceData =

View File

@ -1001,6 +1001,10 @@ PuppetWidget::SetCursor(imgIContainer* aCursor,
RefPtr<mozilla::gfx::DataSourceSurface> dataSurface = RefPtr<mozilla::gfx::DataSourceSurface> dataSurface =
surface->GetDataSurface(); surface->GetDataSurface();
if (!dataSurface) {
return NS_ERROR_FAILURE;
}
size_t length; size_t length;
int32_t stride; int32_t stride;
mozilla::UniquePtr<char[]> surfaceData = mozilla::UniquePtr<char[]> surfaceData =

View File

@ -51,20 +51,21 @@ nsDragServiceProxy::InvokeDragSessionImpl(nsISupportsArray* aArrayTransferables,
RefPtr<mozilla::gfx::DataSourceSurface> dataSurface = RefPtr<mozilla::gfx::DataSourceSurface> dataSurface =
surface->GetDataSurface(); surface->GetDataSurface();
mozilla::gfx::IntSize size = dataSurface->GetSize(); mozilla::gfx::IntSize size = dataSurface->GetSize();
if (dataSurface) {
size_t length;
int32_t stride;
mozilla::UniquePtr<char[]> surfaceData =
nsContentUtils::GetSurfaceData(dataSurface, &length, &stride);
nsDependentCString dragImage(surfaceData.get(), length);
size_t length; mozilla::Unused <<
int32_t stride; child->SendInvokeDragSession(dataTransfers, aActionType, dragImage,
mozilla::UniquePtr<char[]> surfaceData = size.width, size.height, stride,
nsContentUtils::GetSurfaceData(dataSurface, &length, &stride); static_cast<uint8_t>(dataSurface->GetFormat()),
nsDependentCString dragImage(surfaceData.get(), length); dragRect.x, dragRect.y);
StartDragSession();
mozilla::Unused << return NS_OK;
child->SendInvokeDragSession(dataTransfers, aActionType, dragImage, }
size.width, size.height, stride,
static_cast<uint8_t>(dataSurface->GetFormat()),
dragRect.x, dragRect.y);
StartDragSession();
return NS_OK;
} }
} }