[OpenWrt-Devel] [PATCH] usign: fix some resource leaks

Hauke Mehrtens hauke at hauke-m.de
Fri Sep 20 15:37:13 EDT 2019


On 9/2/19 11:27 PM, Rosen Penev wrote:
> On Mon, Sep 2, 2019 at 1:29 PM Hauke Mehrtens <hauke at hauke-m.de> wrote:
>>
>> This fixes some resources leaks mostly in error patches.
>>
>> Coverity: #1330236, #1330237, #1330238
>> Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
>> ---
>>  main.c | 12 ++++++++++--
>>  1 file changed, 10 insertions(+), 2 deletions(-)
>>
>> diff --git a/main.c b/main.c
>> index 3536443..ef47b28 100644
>> --- a/main.c
>> +++ b/main.c
>> @@ -129,6 +129,7 @@ get_file(const char *filename, char *buf, int buflen)
>>
>>         len = fread(buf, 1, buflen - 1, f);
>>         buf[len] = 0;
>> +       fclose(f);
> It's more compact to use __attribute__((cleanup)) instead. Although
> last time I tried making changes like those they were shot sown since
> it's a GNU extension.

Nice feature, I was not aware of it.

I still would use the old way because this is a GNU extension.

Hauke

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/openwrt-devel/attachments/20190920/cf06ea19/attachment.sig>
-------------- next part --------------
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list