Issue 8782 - Memory leak in ldap_cancel
Summary: Memory leak in ldap_cancel
Status: VERIFIED FIXED
Alias: None
Product: OpenLDAP
Classification: Unclassified
Component: slapd (show other issues)
Version: 2.4.45
Hardware: All All
: --- normal
Target Milestone: ---
Assignee: OpenLDAP project
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-12-04 12:38 UTC by cheimes@redhat.com
Modified: 2018-03-22 19:26 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description cheimes@redhat.com 2017-12-04 12:38:03 UTC
Full_Name: Christian Heimes
Version: 2.4.45
OS: Fedora
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (2001:16b8:6097:b200:c324:8c3d:7869:1a1b)


While I was looking for memory leaks in python-ldap, Valgrind detected a memory
leak in ldap_cancel:

==30178== 22 (16 direct, 6 indirect) bytes in 1 blocks are definitely lost in
loss record 27 of 5,810
==30178==    at 0x4C2FB6B: malloc (vg_replace_malloc.c:299)
==30178==    by 0x14CBD9E4: ber_memalloc_x (memory.c:228)
==30178==    by 0x14CBC940: ber_flatten (io.c:437)
==30178==    by 0x14A81733: ldap_cancel (cancel.c:50)
==30178==    by 0x1485A3BA: l_ldap_cancel (LDAPObject.c:779)
==30178==    by 0x4FC24EF: PyCFunction_Call (in
/usr/lib64/libpython3.6m.so.1.0)
==30178==    by 0x4FF891C: _PyEval_EvalFrameDefault (in
/usr/lib64/libpython3.6m.so.1.0)
==30178==    by 0x4F590B2: ??? (in /usr/lib64/libpython3.6m.so.1.0)
==30178==    by 0x4F8BE10: ??? (in /usr/lib64/libpython3.6m.so.1.0)
==30178==    by 0x4FC933D: ??? (in /usr/lib64/libpython3.6m.so.1.0)
==30178==    by 0x4FF2EC9: _PyEval_EvalFrameDefault (in
/usr/lib64/libpython3.6m.so.1.0)
==30178==    by 0x4F590B2: ??? (in /usr/lib64/libpython3.6m.so.1.0)

I think the function is missing a call to ber_bvfree(cancelidvalp).

python-ldap issue: https://github.com/python-ldap/python-ldap/issues/82
Code: https://github.com/openldap/openldap/blob/master/libraries/libldap/cancel.c#L43-L55
Comment 1 Howard Chu 2017-12-04 16:01:08 UTC
cheimes@redhat.com wrote:
> Full_Name: Christian Heimes
> Version: 2.4.45
> OS: Fedora
> URL: ftp://ftp.openldap.org/incoming/
> Submission from: (NULL) (2001:16b8:6097:b200:c324:8c3d:7869:1a1b)
> 
> 
> While I was looking for memory leaks in python-ldap, Valgrind detected a memory
> leak in ldap_cancel:

Thanks for the report. Fixed now in master.
> 
> ==30178== 22 (16 direct, 6 indirect) bytes in 1 blocks are definitely lost in
> loss record 27 of 5,810
> ==30178==    at 0x4C2FB6B: malloc (vg_replace_malloc.c:299)
> ==30178==    by 0x14CBD9E4: ber_memalloc_x (memory.c:228)
> ==30178==    by 0x14CBC940: ber_flatten (io.c:437)
> ==30178==    by 0x14A81733: ldap_cancel (cancel.c:50)
> ==30178==    by 0x1485A3BA: l_ldap_cancel (LDAPObject.c:779)
> ==30178==    by 0x4FC24EF: PyCFunction_Call (in
> /usr/lib64/libpython3.6m.so.1.0)
> ==30178==    by 0x4FF891C: _PyEval_EvalFrameDefault (in
> /usr/lib64/libpython3.6m.so.1.0)
> ==30178==    by 0x4F590B2: ??? (in /usr/lib64/libpython3.6m.so.1.0)
> ==30178==    by 0x4F8BE10: ??? (in /usr/lib64/libpython3.6m.so.1.0)
> ==30178==    by 0x4FC933D: ??? (in /usr/lib64/libpython3.6m.so.1.0)
> ==30178==    by 0x4FF2EC9: _PyEval_EvalFrameDefault (in
> /usr/lib64/libpython3.6m.so.1.0)
> ==30178==    by 0x4F590B2: ??? (in /usr/lib64/libpython3.6m.so.1.0)
> 
> I think the function is missing a call to ber_bvfree(cancelidvalp).
> 
> python-ldap issue: https://github.com/python-ldap/python-ldap/issues/82
> Code: https://github.com/openldap/openldap/blob/master/libraries/libldap/cancel.c#L43-L55
> 
> 


-- 
   -- Howard Chu
   CTO, Symas Corp.           http://www.symas.com
   Director, Highland Sun     http://highlandsun.com/hyc/
   Chief Architect, OpenLDAP  http://www.openldap.org/project/

Comment 2 Quanah Gibson-Mount 2018-02-08 18:38:48 UTC
changed notes
changed state Open to Test
moved from Incoming to Software Bugs
Comment 3 Quanah Gibson-Mount 2018-02-09 17:36:09 UTC
changed notes
changed state Test to Release
Comment 4 OpenLDAP project 2018-03-22 19:26:41 UTC
fixed in master
Fixed in RE24 (2.4.46)
Comment 5 Quanah Gibson-Mount 2018-03-22 19:26:41 UTC
changed notes
changed state Release to Closed