[SSSD] [PATCH] Every time release allocated memory in function
Lukas Slebodnik
lslebodn at redhat.com
Wed Jul 24 12:09:22 UTC 2013
On (24/07/13 13:52), Jakub Hrozek wrote:
>On Wed, Jul 24, 2013 at 12:06:41PM +0200, Lukas Slebodnik wrote:
>> ehlo,
>>
>> Memory leak was found by coverity. (and also by scan-build)
>>
>> Patch is attached.
>>
>> LS
>
>> From 5b84e6f9114b623c01cb0bc50ae7405c6225c91f Mon Sep 17 00:00:00 2001
>> From: Lukas Slebodnik <lslebodn at redhat.com>
>> Date: Wed, 24 Jul 2013 10:52:08 +0200
>> Subject: [PATCH] Every time release allocated memory in function
>> py_sss_getgrouplist
>>
>> Coverity: 11922
>> ---
>> src/python/pysss.c | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/src/python/pysss.c b/src/python/pysss.c
>> index 4dd0351354aadb185a25f5c54e945f8397d7dcf7..284947be184054122b425b31e42615b1fa10b2e2 100644
>> --- a/src/python/pysss.c
>> +++ b/src/python/pysss.c
>> @@ -804,6 +804,7 @@ static PyObject *py_sss_getgrouplist(PyObject *self, PyObject *args)
>> idx++;
>> }
>> }
>> + free(groups);
>>
>
>Nice catch but I would prefer if you also set groups to NULL here so
>that if in the future we add a goto fail to the code after the groups
>array is freed, we don't attempt to free groups again.
Thank you for review.
Updated patch is attached.
LS
-------------- next part --------------
>From 4eea5a266be94b7ecee2d48326019c8cff4bcb50 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn at redhat.com>
Date: Wed, 24 Jul 2013 10:52:08 +0200
Subject: [PATCH] Every time release allocated memory in function
py_sss_getgrouplist
Coverity: 11922
---
src/python/pysss.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/python/pysss.c b/src/python/pysss.c
index 4dd0351354aadb185a25f5c54e945f8397d7dcf7..8f9a20b684ecfbccd8929f8b5689c8169d599ff4 100644
--- a/src/python/pysss.c
+++ b/src/python/pysss.c
@@ -804,6 +804,8 @@ static PyObject *py_sss_getgrouplist(PyObject *self, PyObject *args)
idx++;
}
}
+ free(groups);
+ groups = NULL;
if (i != idx) {
_PyTuple_Resize(&groups_tuple, idx);
--
1.8.3.1
More information about the sssd-devel
mailing list