Re: [PATCH 1/1] mcstrans: fix memory leaks reported by clang's static analyzer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jul 3, 2018 at 12:49 AM, William Roberts
<bill.c.roberts@xxxxxxxxx> wrote:
> On Mon, Jul 2, 2018 at 11:38 AM, Nicolas Iooss <nicolas.iooss@xxxxxxx> wrote:
>> On Sun, Jul 1, 2018 at 10:51 PM, William Roberts
>> <bill.c.roberts@xxxxxxxxx> wrote:
>>> I see lots of repeating blocks, would it make more sense to goto an
>>> error label and free them then return -1?
>>
>> Both trans_context() and untrans_context() currently define "char
>> *ltrans = NULL, *utrans = NULL;" and "char *lrange = NULL, *urange =
>> NULL;" in the body of a for loop. Introducing an error label at the
>> end of these functions requires moving these definition outside of the
>> loop (which could introduce side effects) and introducing the label at
>> the end of the loop makes the code less readable, IMHO. I guess this
>> could explain why the current code does not use a "goto error" or
>> "goto clean" approach and leaks memory where an error occurs.
>>
>> Anyway, if you are fine with moving the definitions of some variables
>> (ltrans and utrans for trans_context(), lrange and urange for
>> untrans_context()), I can write, test and send a new patch with a
>> "goto error" instead of several free().
>
> This seems fine. I just applied and tested this (finally). Ack.

Thanks. I applied the 3 patches that I sent.

Nicolas

_______________________________________________
Selinux mailing list
Selinux@xxxxxxxxxxxxx
To unsubscribe, send email to Selinux-leave@xxxxxxxxxxxxx.
To get help, send an email containing "help" to Selinux-request@xxxxxxxxxxxxx.



[Index of Archives]     [Selinux Refpolicy]     [Linux SGX]     [Fedora Users]     [Fedora Desktop]     [Yosemite Photos]     [Yosemite Camping]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

  Powered by Linux