1 diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
2 index e9e544d..cde68a1 100644
3 --- a/src/cairo-image-surface.c
4 +++ b/src/cairo-image-surface.c
5 @@ -324,8 +324,8 @@ _cairo_image_surface_create_with_pixman_format (unsigned char *data,
6 cairo_surface_t *surface;
7 pixman_image_t *pixman_image;
9 - pixman_image = pixman_image_create_bits (pixman_format, width, height,
10 - (uint32_t *) data, stride);
11 + pixman_image = pixman_image_create_bits (pixman_format, width ? width : 1, height ? height : 1,
12 + (uint32_t *) data, stride ? stride : 4);
14 if (unlikely (pixman_image == NULL))
15 return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
16 diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
17 index f86a133..ddcb600 100644
18 --- a/src/cairo-xlib-surface.c
19 +++ b/src/cairo-xlib-surface.c
20 @@ -675,7 +675,8 @@ _get_image_surface (cairo_xlib_surface_t *surface,
22 pixmap = XCreatePixmap (surface->dpy,
24 - extents.width, extents.height,
25 + extents.width <= 0 ? 1 : extents.width,
26 + extents.height <= 0 ? 1 : extents.height,
29 XCopyArea (surface->dpy, surface->drawable, pixmap, surface->gc,
30 @@ -686,7 +687,8 @@ _get_image_surface (cairo_xlib_surface_t *surface,
31 ximage = XGetImage (surface->dpy,
34 - extents.width, extents.height,
35 + extents.width <= 0 ? 1 : extents.width,
36 + extents.height <= 0 ? 1 : extents.height,
39 XFreePixmap (surface->dpy, pixmap);