[cairo] libpixman leak
sandmann at daimi.au.dk
Tue Apr 22 13:05:57 PDT 2008
Tim Janik <timj at imendio.com> writes:
> We've had a leak reported with the following patch attached.
> The test case used was running a Gtk+ example program in valgrind
> with progressbars that show text. Does the following look like an
> appropriate leak fix for you?
I can try and explain how the code is supposed to work, if that's
helpful. The pixman_alloc_rect() is intended to allocate space for n
In the first clause of the if statement, the region has no data
associated with it, which means the region consists of just one
rectangle. This rectangle is stored in the extents field. The n++
there is to allocate space for both the extents rectangle, and the n
In the second clause, data->size is 0, which means data points to a
statically allocated _pixman_region_emptyBox. This is why we don't
free anything there.
Finally, in the third clause we do something resembling a doubling
reallocation, except gratuitously complicated because this code
originally came from the X server.
Adding an extra n++ in the second clause would just cause us to
allocate space for an extra rectangle, which would not generally be
harmful, but shouldn't fix any leaks either. So, no, I don't see how
this could be an appropriate leak fix, but on the other hand, it's
fairly complicated code, so I could have missed something.
A stand-alone pixman testcase demonstrating the leak would be useful.
More information about the cairo