From 2f416d4188e35b09b60671d8a7efa7cbc6fea4b2 Mon Sep 17 00:00:00 2001 From: Timothy Nikkel Date: Thu, 26 Aug 2010 22:01:43 -0500 Subject: [PATCH] imported patch returnnullincreatesimilar --- gfx/thebes/gfxASurface.cpp | 4 ++++ gfx/thebes/gfxXlibSurface.cpp | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/gfx/thebes/gfxASurface.cpp b/gfx/thebes/gfxASurface.cpp index bc04330d125..0ff6309a395 100644 --- a/gfx/thebes/gfxASurface.cpp +++ b/gfx/thebes/gfxASurface.cpp @@ -310,6 +310,10 @@ already_AddRefed gfxASurface::CreateSimilarSurface(gfxContentType aContent, const gfxIntSize& aSize) { + if (!mSurface || !mSurfaceValid) { + return nsnull; + } + cairo_surface_t *surface = cairo_surface_create_similar(mSurface, cairo_content_t(aContent), aSize.width, aSize.height); diff --git a/gfx/thebes/gfxXlibSurface.cpp b/gfx/thebes/gfxXlibSurface.cpp index 1fc7f4821a0..9b5621e3575 100644 --- a/gfx/thebes/gfxXlibSurface.cpp +++ b/gfx/thebes/gfxXlibSurface.cpp @@ -182,6 +182,10 @@ already_AddRefed gfxXlibSurface::CreateSimilarSurface(gfxContentType aContent, const gfxIntSize& aSize) { + if (!mSurface || !mSurfaceValid) { + return nsnull; + } + if (aContent == CONTENT_COLOR) { // cairo_surface_create_similar will use a matching visual if it can. // However, systems with 16-bit or indexed default visuals may benefit