Bug 678982 - check for null pointer dereference in gfx/layers/d3d10/ImageLayerD3D10.cpp; r=bas.schouten

This commit is contained in:
aceman 2012-01-19 15:53:56 +01:00
parent 58bfc9b21e
commit 85d9ceee4c

View File

@ -50,7 +50,11 @@ SurfaceToTexture(ID3D10Device *aDevice,
gfxASurface *aSurface,
const gfxIntSize &aSize)
{
if (aSurface && aSurface->GetType() == gfxASurface::SurfaceTypeD2D) {
if (!aSurface) {
return NULL;
}
if (aSurface->GetType() == gfxASurface::SurfaceTypeD2D) {
void *data = aSurface->GetData(&gKeyD3D10Texture);
if (data) {
nsRefPtr<ID3D10Texture2D> texture = static_cast<ID3D10Texture2D*>(data);
@ -67,7 +71,7 @@ SurfaceToTexture(ID3D10Device *aDevice,
if (!imageSurface) {
imageSurface = new gfxImageSurface(aSize,
gfxASurface::ImageFormatARGB32);
nsRefPtr<gfxContext> context = new gfxContext(imageSurface);
context->SetSource(aSurface);
context->SetOperator(gfxContext::OPERATOR_SOURCE);
@ -75,13 +79,13 @@ SurfaceToTexture(ID3D10Device *aDevice,
}
D3D10_SUBRESOURCE_DATA data;
CD3D10_TEXTURE2D_DESC desc(DXGI_FORMAT_B8G8R8A8_UNORM,
imageSurface->GetSize().width,
imageSurface->GetSize().height,
1, 1);
desc.Usage = D3D10_USAGE_IMMUTABLE;
data.pSysMem = imageSurface->Data();
data.SysMemPitch = imageSurface->Stride();