Don't crash on 0-width or 0-height glyphs; also correctly initialize entry->key.base.memory with the image cache image.

Free allocated entry in case of error to avoid leaking memory.
This commit is contained in:
Vladimir Vukicevic 2005-08-09 13:42:54 +00:00
parent cedf233052
commit 8042a0d219
3 changed files with 45 additions and 2 deletions

View file

@ -1,3 +1,12 @@
2005-08-09 Vladimir Vukicevic <vladimir@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.
2005-08-09 Carl Worth <cworth@cworth.org>
* src/cairo-arc-private.h:

View file

@ -1266,6 +1266,9 @@ static cairo_status_t
_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_create_entry (void *abstract_cache,
{
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);

View file

@ -1920,12 +1920,15 @@ _xlib_glyphset_cache_create_entry (void *abstract_cache,
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;
}