Bug 589891 - d2d 0-sized surfaces shouldn't cause a Cxx exception. r=jmuizelaar, a2.0=blocking-beta5
authorVladimir Vukicevic <vladimir@pobox.com>
Mon, 23 Aug 2010 20:12:11 -0700
changeset 51306 4747f09a62e399f5ac0c2bcb16736a047c03b996
parent 51305 1a83b122acf2cf19e2a5e61a7b20d5dceec96aac
child 51307 b8e409a955c1105ae26ea1c402c0116b4708b585
push idunknown
push userunknown
push dateunknown
reviewersjmuizelaar
bugs589891
milestone2.0b5pre
Bug 589891 - d2d 0-sized surfaces shouldn't cause a Cxx exception. r=jmuizelaar, a2.0=blocking-beta5
gfx/cairo/cairo/src/cairo-d2d-surface.cpp
--- a/gfx/cairo/cairo/src/cairo-d2d-surface.cpp
+++ b/gfx/cairo/cairo/src/cairo-d2d-surface.cpp
@@ -3426,16 +3426,20 @@ FAIL_HWND:
 }
 
 cairo_surface_t *
 cairo_d2d_surface_create(cairo_device_t *device,
 			 cairo_format_t format,
                          int width,
                          int height)
 {
+    if (width == 0 || height == 0) {
+	return _cairo_surface_create_in_error(_cairo_error(CAIRO_STATUS_INVALID_SIZE));
+    }
+
     cairo_d2d_device_t *d2d_device = reinterpret_cast<cairo_d2d_device_t*>(device);
     cairo_d2d_surface_t *newSurf = static_cast<cairo_d2d_surface_t*>(malloc(sizeof(cairo_d2d_surface_t)));
     new (newSurf) cairo_d2d_surface_t();
 
     DXGI_FORMAT dxgiformat = DXGI_FORMAT_B8G8R8A8_UNORM;
     D2D1_ALPHA_MODE alpha = D2D1_ALPHA_MODE_PREMULTIPLIED;
     if (format == CAIRO_FORMAT_ARGB32) {
 	_cairo_surface_init(&newSurf->base, &cairo_d2d_surface_backend, CAIRO_CONTENT_COLOR_ALPHA);