Bug 577631. Don't pass zero sizes to XCreatePixmap. r=jrmuizel
authorRobert O'Callahan <robert@ocallahan.org>
Fri, 16 Jul 2010 09:08:09 +1200
changeset 47764 c117f649feed14637666c5dbcfcba18c790b5817
parent 47763 d0fb245dcb3484f19aa3614219c28f77dc587e66
child 47765 fa2e4fe69310b212b5c651cba35656e26549fb55
push id14413
push userrocallahan@mozilla.com
push dateThu, 15 Jul 2010 21:12:02 +0000
treeherderautoland@e1d7fd5255fd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs577631
milestone2.0b2pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 577631. Don't pass zero sizes to XCreatePixmap. r=jrmuizel
gfx/thebes/gfxXlibSurface.cpp
--- a/gfx/thebes/gfxXlibSurface.cpp
+++ b/gfx/thebes/gfxXlibSurface.cpp
@@ -39,16 +39,17 @@
 #include "gfxXlibSurface.h"
 
 #include "cairo.h"
 #include "cairo-xlib.h"
 #include "cairo-xlib-xrender.h"
 #include <X11/Xlibint.h>	/* For XESetCloseDisplay */
 
 #include "nsTArray.h"
+#include "nsAlgorithm.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIPrefService.h"
 
 // Although the dimension parameters in the xCreatePixmapReq wire protocol are
 // 16-bit unsigned integers, the server's CreatePixmap returns BadAlloc if
 // either dimension cannot be represented by a 16-bit *signed* integer.
 #define XLIB_IMAGE_SIDE_SIZE_LIMIT 0x7fff
 
@@ -112,18 +113,21 @@ CreatePixmap(Screen *screen, const gfxIn
 {
     if (!gfxASurface::CheckSurfaceSize(size, XLIB_IMAGE_SIDE_SIZE_LIMIT))
         return None;
 
     if (relatedDrawable == None) {
         relatedDrawable = RootWindowOfScreen(screen);
     }
     Display *dpy = DisplayOfScreen(screen);
+    // X gives us a fatal error if we try to create a pixmap of width
+    // or height 0
     return XCreatePixmap(dpy, relatedDrawable,
-                         size.width, size.height, depth);
+                         NS_MAX(1, size.width), NS_MAX(1, size.height),
+                         depth);
 }
 
 /* static */
 already_AddRefed<gfxXlibSurface>
 gfxXlibSurface::Create(Screen *screen, Visual *visual,
                        const gfxIntSize& size, Drawable relatedDrawable)
 {
     Drawable drawable =