[cairo] Fix some memory leaks + double free

Sylvestre Ledru sylvestre at mozilla.com
Fri May 9 02:30:41 PDT 2014


On 08/05/2014 21:45, Uli Schlachter wrote:
> On 07.05.2014 19:04, Sylvestre Ledru wrote:
>> From 3cb1dd13903014814dced740d785b101c17fd622 Mon Sep 17 00:00:00 2001
>> From: Sylvestre Ledru <sylvestre at mozilla.com>
>> Date: Wed, 7 May 2014 17:15:22 +0200
>> Subject: [PATCH 1/2] Fix some memory leaks found by scan-build, the LLVM/Clang
>>  static analyzer
> [...]
>> diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
>> index c200c28..8e92df2 100644
>> --- a/src/cairo-pdf-surface.c
>> +++ b/src/cairo-pdf-surface.c
>> @@ -2645,8 +2645,10 @@ _cairo_pdf_surface_lookup_jbig2_global (cairo_pdf_surface_t       *surface,
>>      memcpy (global.id, global_id, global_id_length);
>>      global.id_length = global_id_length;
>>      global.res = _cairo_pdf_surface_new_object (surface);
>> -    if (global.res.id == 0)
>> +    if (global.res.id == 0) {
> 
> Could you make this "if (global.id == NULL || global.res.id == 0) {"?
> 
> Hm, no, would also have to free global.res in this case... Uhm...
> 
> Add a check for malloc() failure after the line that sets global.id, please.
Sure. Done. Thanks for the review.

Here are the two patches updated.

Cheers,
Sylvestre

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Fix-some-memory-leaks-found-by-scan-build-the-LLVM-C.patch
Type: text/x-patch
Size: 2293 bytes
Desc: not available
URL: <http://lists.cairographics.org/archives/cairo/attachments/20140509/19f22c06/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Remove-some-potential-double-free.patch
Type: text/x-patch
Size: 847 bytes
Desc: not available
URL: <http://lists.cairographics.org/archives/cairo/attachments/20140509/19f22c06/attachment-0001.bin>


More information about the cairo mailing list