From ff3b047be8b6e4098859b2330bf23482b1612a33 Mon Sep 17 00:00:00 2001 From: aceman Date: Thu, 19 Jan 2012 15:53:56 +0100 Subject: [PATCH] Bug 678982 - check for null pointer dereference in gfx/layers/d3d10/ImageLayerD3D10.cpp; r=bas.schouten --- gfx/layers/d3d10/ImageLayerD3D10.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/gfx/layers/d3d10/ImageLayerD3D10.cpp b/gfx/layers/d3d10/ImageLayerD3D10.cpp index d5b83e44a93..f598e1d969e 100644 --- a/gfx/layers/d3d10/ImageLayerD3D10.cpp +++ b/gfx/layers/d3d10/ImageLayerD3D10.cpp @@ -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 texture = static_cast(data); @@ -67,7 +71,7 @@ SurfaceToTexture(ID3D10Device *aDevice, if (!imageSurface) { imageSurface = new gfxImageSurface(aSize, gfxASurface::ImageFormatARGB32); - + nsRefPtr 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();