From 9fcd092ce1d59a19a74f48cdbdfbe71bd5f18f9e Mon Sep 17 00:00:00 2001 From: Michael Henning Date: Sun, 21 Jul 2013 22:55:57 -0400 Subject: [PATCH] win32: Fix image surface freeing loop Previously, _cairo_win32_display_surface_finish could attempt to destroy its patrent while the parent was in the process of being destroyed. This simply checks to see if the parent's refcount is zero before freeing it. https://bugs.freedesktop.org/show_bug.cgi?id=63787 --- src/win32/cairo-win32-display-surface.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/win32/cairo-win32-display-surface.c b/src/win32/cairo-win32-display-surface.c index 0390625..f4d27bb 100644 --- a/src/win32/cairo-win32-display-surface.c +++ b/src/win32/cairo-win32-display-surface.c @@ -415,7 +415,8 @@ _cairo_win32_display_surface_finish (void *abstract_surface) { cairo_win32_display_surface_t *surface = abstract_surface; - if (surface->image) { + if (surface->image && + CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&surface->image->ref_count)) { /* Unhook ourselves first to avoid the double-unref from the image */ to_image_surface(surface->image)->parent = NULL; cairo_surface_finish (surface->image); -- 1.8.3.3