[cairo] memory leak in Cairo/pixman - PATCH

Jan Slupski jslupski at juljas.net
Thu Feb 14 16:44:27 PST 2008


On Fri, 15 Feb 2008, Jan Slupski wrote:

> On Thu, 14 Feb 2008, Jan Slupski wrote:
>
>>
>> Hi,
>>
>> I've been tracing a memory leak that appears to come from Cairo.
>> I'm using 1.4.12, but 1.4.14 seems to be quite the same in that context.
>
> Following the discussion on the IRC, here is a port of 1.6 patch for
> that leak.

Sorry, patch broken (probably) by the mail client. 
Resending to test out the other way of attaching it.

Jan

    _  _  _  _  _____________________________________________
    | |_| |\ |  S L U P S K I             jslupski at juljas.net
  |_| | | | \|                             http://juljas.net/
-------------- next part --------------
From 7647f29a2a3b69592e38f50890a96d8deeaa2dbb Mon Sep 17 00:00:00 2001
From: Jan Slupski <jslupski at juljas.net>
Date: Fri, 15 Feb 2008 00:55:30 +0100
Subject: [PATCH] Fix for a memory leak in pixman.

Port of a 1.6 fix for a memory leak in pixman_region_init_rects/pixman_rect_alloc
when the count of boxes is 0.
---
 pixman/src/pixregion.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/pixman/src/pixregion.c b/pixman/src/pixregion.c
index 1ed3ad7..d6caf6c 100644
--- a/pixman/src/pixregion.c
+++ b/pixman/src/pixregion.c
@@ -355,6 +355,15 @@ pixman_region_init_rects(pixman_region16_t *region, pixman_box16_t *boxes, int c
     }
 
     pixman_region_init(region);
+
+    /* if it's 0, don't call pixman_rect_alloc -- 0 rectangles is
+     * a special case, and causing pixman_rect_alloc would cause
+     * us to leak memory (because the 0-rect case should be the
+     * static pixman_region_emptyData data).
+     */
+    if (count == 0)
+        return PIXMAN_REGION_STATUS_SUCCESS;
+
     if (!pixman_rect_alloc(region, count))
 	return PIXMAN_REGION_STATUS_FAILURE;
 
-- 
1.5.3.8



More information about the cairo mailing list