[cairo] Leak in win32 display surface

Zozó Teki teknos at gmail.com
Fri Feb 15 05:58:28 PST 2013


Hi,

I noticed that a win32 surface does not destroy its fallback image.

Creating a win32 display surface, doing something that creates the fallback
and deleting the win32 surface will leak the fallback surface.

In the below patch (against 1.12.14) I do 2 things.

1. In _cairo_win32_display_surface_finish I add code to destroy the
fallback image.
2. In _cairo_win32_display_surface_flush I modify the code to destroy the
fallback image even if there was damage made to it (of course only after
flushing the damage).

Any comments?

Zoltan



--- C:/Users/ethzrt/Documents/msc-generator/cairo-win32-display-surface.c Sun
Feb 10 14:07:15 2013
+++
C:/Users/ethzrt/Documents/msc-generator/cairo/src/win32/cairo-win32-display-surface.c
Fri
Feb 15 14:25:42 2013
@@ -428,6 +428,12 @@
  DeleteObject (surface->bitmap);
  DeleteDC (surface->win32.dc);
     }
+
+    /* Zozo If we created a fallback image, destroy it */
+    if (surface->fallback) {
+ cairo_surface_finish (surface->fallback);
+ cairo_surface_destroy (surface->fallback);
+    }

     if (surface->initial_clip_rgn)
  DeleteObject (surface->initial_clip_rgn);
@@ -568,10 +574,10 @@
     }
  }
  _cairo_damage_destroy (damage);
-    } else {
+    }
+
  cairo_surface_destroy (surface->fallback);
  surface->fallback = NULL;
-    }

     return status;
 }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20130215/00eea059/attachment.html>


More information about the cairo mailing list