surface: Prevent reads from the user-data arrays during teardown

In a similar fashion to the previous commit, we also need to be wary of
users simply trying to read from a potentially freed user-data array.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson 2013-02-02 08:47:26 +00:00
parent 18cff63e3d
commit 10110d58ce

View file

@ -1096,6 +1096,10 @@ void *
cairo_surface_get_user_data (cairo_surface_t *surface,
const cairo_user_data_key_t *key)
{
/* Prevent reads of the array during teardown */
if (! CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&surface->ref_count))
return NULL;
return _cairo_user_data_array_get_data (&surface->user_data, key);
}
@ -1157,7 +1161,9 @@ cairo_surface_get_mime_data (cairo_surface_t *surface,
*data = NULL;
*length = 0;
if (unlikely (surface->status))
/* Prevent reads of the array during teardown */
if (! CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&surface->ref_count))
return;
/* The number of mime-types attached to a surface is usually small,