[cairo-commit] cairo/src cairo-glitz-surface.c, 1.56, 1.57 cairo-xlib-surface.c, 1.107, 1.108

Vladimir Vukicevic commit at pdx.freedesktop.org
Tue Aug 9 13:42:56 PDT 2005


Committed by: vladimir

Update of /cvs/cairo/cairo/src
In directory gabe:/tmp/cvs-serv19753/src

Modified Files:
	cairo-glitz-surface.c cairo-xlib-surface.c 
Log Message:
2005-08-09  Vladimir Vukicevic  <vladimir at pobox.com>

	* src/cairo-glitz-surface.c: Don't crash on 0-width or 0-height
	glyphs; also correctly initialize entry->key.base.memory with the
	image cache image.

	* src/cairo-xlib-surface.c (_xlib_glyphset_cache_create_entry):
	Free allocated entry in case of error to avoid leaking memory.



Index: cairo-glitz-surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-glitz-surface.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -d -r1.56 -r1.57
--- cairo-glitz-surface.c	9 Aug 2005 01:35:22 -0000	1.56
+++ cairo-glitz-surface.c	9 Aug 2005 20:42:54 -0000	1.57
@@ -1266,6 +1266,9 @@
 _cairo_glitz_area_move_in (cairo_glitz_area_t *area,
 			   void		      *closure)
 {
+    if (area == &_empty_area)
+	return CAIRO_STATUS_SUCCESS;
+
     area->closure = closure;
     area->state   = CAIRO_GLITZ_AREA_OCCUPIED;
     
@@ -1610,14 +1613,42 @@
 {
     cairo_glitz_glyph_cache_entry_t *entry;
     cairo_glyph_cache_key_t	    *key = abstract_key;
-    
+   
+    cairo_status_t status;
+    cairo_cache_t *im_cache;
+    cairo_image_glyph_cache_entry_t *im;
+
+    unsigned long entry_memory = 0;
+
     entry = malloc (sizeof (cairo_glitz_glyph_cache_entry_t));
     if (!entry)
 	return CAIRO_STATUS_NO_MEMORY;
 
+    _cairo_lock_global_image_glyph_cache ();
+
+    im_cache = _cairo_get_global_image_glyph_cache ();
+    if (im_cache == NULL) {
+	_cairo_unlock_global_image_glyph_cache ();
+	free (entry);
+	return CAIRO_STATUS_NO_MEMORY;
+    }
+
+    status = _cairo_cache_lookup (im_cache, key, (void **) (&im), NULL);
+    if (status != CAIRO_STATUS_SUCCESS || im == NULL) {
+	_cairo_unlock_global_image_glyph_cache ();
+	free (entry);
+	return CAIRO_STATUS_NO_MEMORY;
+    }
+
+    if (im->image)
+	entry_memory = im->image->width * im->image->stride;
+
+    _cairo_unlock_global_image_glyph_cache ();
+
     entry->ref_count = 1;
     entry->key	    = *key;
-    entry->area     = NULL;
+    entry->key.base.memory = entry_memory;
+    entry->area	    = NULL;
     entry->locked   = FALSE;
 
     _cairo_unscaled_font_reference (entry->key.unscaled);

Index: cairo-xlib-surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-xlib-surface.c,v
retrieving revision 1.107
retrieving revision 1.108
diff -u -d -r1.107 -r1.108
--- cairo-xlib-surface.c	9 Aug 2005 01:35:22 -0000	1.107
+++ cairo-xlib-surface.c	9 Aug 2005 20:42:54 -0000	1.108
@@ -1920,12 +1920,15 @@
 
     if (cache == NULL || entry == NULL || im_cache == NULL) {
 	_cairo_unlock_global_image_glyph_cache ();
+	if (entry)
+	    free (entry);
 	return CAIRO_STATUS_NO_MEMORY;
     }
 
     status = _cairo_cache_lookup (im_cache, key, (void **) (&im), NULL);
     if (status != CAIRO_STATUS_SUCCESS || im == NULL) {
 	_cairo_unlock_global_image_glyph_cache ();
+	free (entry);
 	return CAIRO_STATUS_NO_MEMORY;
     }
 




More information about the cairo-commit mailing list