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
Родитель c1d6cae081
Коммит ff3b047be8
1 изменённых файлов: 8 добавлений и 4 удалений

Просмотреть файл

@ -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();