diff --git a/widgets/rb-fading-image.c b/widgets/rb-fading-image.c
index ec73f28..dab0370 100644
--- a/widgets/rb-fading-image.c
+++ b/widgets/rb-fading-image.c
@@ -644,8 +661,18 @@ composite_into_current (RBFadingImage *image)
 	int width;
 	int height;
 
+	if (image->priv->current_pat != NULL) {
+		cairo_pattern_destroy (image->priv->current_pat);
+	}
 	width = gtk_widget_get_allocated_width (GTK_WIDGET (image)) - 2 * BORDER_WIDTH;
 	height = gtk_widget_get_allocated_height (GTK_WIDGET (image)) - 2 * BORDER_WIDTH;
+	if (width < 1 || height < 1) {
+		image->priv->current_pat = NULL;
+		image->priv->current_width = 0;
+		image->priv->current_height = 0;
+		return;
+	}
+
 	dest = cairo_image_surface_create (CAIRO_FORMAT_RGB24, width, height);
 
 	cr = cairo_create (dest);
@@ -653,9 +680,6 @@ composite_into_current (RBFadingImage *image)
 	render_next (image, cr, width, height, FALSE);
 	cairo_destroy (cr);
 
-	if (image->priv->current_pat != NULL) {
-		cairo_pattern_destroy (image->priv->current_pat);
-	}
 	image->priv->current_pat = cairo_pattern_create_for_surface (dest);
 	image->priv->current_width = width;
 	image->priv->current_height = height;
diff --git a/widgets/rb-import-dialog.c b/widgets/rb-import-dialog.c
