Index: src/cairo-ft-font.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-ft-font.c,v
retrieving revision 1.115
diff -u -p -r1.115 cairo-ft-font.c
--- src/cairo-ft-font.c	21 Dec 2005 16:19:47 -0000	1.115
+++ src/cairo-ft-font.c	26 Jan 2006 01:01:58 -0000
@@ -699,7 +699,7 @@ _native_byte_order_lsb (void)
     return *((char *) &x) == 1;
 }
 
-/* Fills in val->image with an image surface created from @bitmap
+/* Fills in *surface with an image surface created from @bitmap
  */
 static cairo_status_t
 _get_bitmap_surface (FT_Bitmap		     *bitmap,
@@ -892,13 +892,15 @@ _get_bitmap_surface (FT_Bitmap		     *bi
 						 width, height, stride);
 	if ((*surface)->base.status) {
 	    free (data);
+	    cairo_surface_destory (*surface);
+	    *surface = NULL;
 	    return CAIRO_STATUS_NO_MEMORY;
 	}
 	
 	if (subpixel)
 	    pixman_image_set_component_alpha ((*surface)->pixman_image, TRUE);
 
-	_cairo_image_surface_assume_ownership_of_data ((*surface));
+	_cairo_image_surface_assume_ownership_of_data (*surface);
     }
 
     return CAIRO_STATUS_SUCCESS;
@@ -1074,15 +1076,19 @@ _render_glyph_bitmap (FT_Face		      fac
     if (error)
 	return CAIRO_STATUS_NO_MEMORY;
 
-    _get_bitmap_surface (&glyphslot->bitmap, FALSE, font_options, surface);
+    status = _get_bitmap_surface (&glyphslot->bitmap, FALSE, font_options, surface);
+    if (status)
+        return status;
     
     /*
      * Note: the font's coordinate system is upside down from ours, so the
      * Y coordinate of the control box needs to be negated.
      */
 
-    (*surface)->base.device_x_offset = glyphslot->bitmap_left;
-    (*surface)->base.device_y_offset = -glyphslot->bitmap_top;
+    if (*surface) {
+        (*surface)->base.device_x_offset = glyphslot->bitmap_left;
+        (*surface)->base.device_y_offset = -glyphslot->bitmap_top;
+    }
 
     return status;
 }

