[scaled-font] Fix implementation-face refleak

If we found the font via the holdover cache, or if we returned due to an
error, we would leak a reference count on the implementaton face.
This commit is contained in:
Chris Wilson 2009-08-28 17:10:35 +01:00
parent e5d44937f3
commit afea5eb79d

View file

@ -950,7 +950,6 @@ cairo_scaled_font_create (cairo_font_face_t *font_face,
_cairo_scaled_font_init_key (&key, font_face,
font_matrix, ctm, options);
}
else
{
@ -1018,6 +1017,8 @@ cairo_scaled_font_create (cairo_font_face_t *font_face,
_cairo_scaled_font_map_unlock ();
cairo_scaled_font_destroy (old);
if (font_face != original_font_face)
cairo_font_face_destroy (font_face);
return scaled_font;
}
@ -1035,12 +1036,18 @@ cairo_scaled_font_create (cairo_font_face_t *font_face,
/* Did we leave the backend in an error state? */
if (unlikely (status)) {
_cairo_scaled_font_map_unlock ();
if (font_face != original_font_face)
cairo_font_face_destroy (font_face);
status = _cairo_font_face_set_error (font_face, status);
return _cairo_scaled_font_create_in_error (status);
}
/* Or did we encounter an error whilst constructing the scaled font? */
if (unlikely (scaled_font->status)) {
_cairo_scaled_font_map_unlock ();
if (font_face != original_font_face)
cairo_font_face_destroy (font_face);
return scaled_font;
}