Bug 914195. Improve type safety in cairo_win32_surface_create_with_d3dsurface9. r=benwa

This avoids a crash by writing to d3d9surface member on surfaces
that are not win32

--HG--
extra : rebase_source : 0aa7a67151c8d30f0b57e50a1f8570abd18081ca
This commit is contained in:
Jeff Muizelaar 2013-09-13 13:39:38 -04:00
parent 901127de6e
commit a86f06f097
2 changed files with 6 additions and 4 deletions

View File

@ -2115,13 +2115,15 @@ cairo_public cairo_surface_t *
cairo_win32_surface_create_with_d3dsurface9 (IDirect3DSurface9 *surface)
{
HDC dc;
cairo_win32_surface_t *win_surface;
cairo_surface_t *win_surface;
IDirect3DSurface9_AddRef (surface);
IDirect3DSurface9_GetDC (surface, &dc);
win_surface = cairo_win32_surface_create_internal(dc, CAIRO_FORMAT_RGB24);
win_surface->d3d9surface = surface;
return (cairo_surface_t*) win_surface;
if (likely(win_surface->status == CAIRO_STATUS_SUCCESS)) {
((cairo_win32_surface_t*)win_surface)->d3d9surface = surface;
}
return win_surface;
}
/**

View File

@ -379,7 +379,7 @@ OpaqueRenderer::Begin(LayerD3D9* aLayer)
}
nsRefPtr<gfxWindowsSurface> result = new gfxWindowsSurface(mSurface);
if (!result) {
if (!result || result->CairoStatus()) {
NS_WARNING("Failed to d3d9 cairo surface.");
return nullptr;
}