Skip to content

lib:util:loadparm - fix leak in lpcfg_dump_a_parameter

This is an OCD fix and so it is fairly low priority. lpcfg_dump_a_parameter doesn't free a temporary string allocated under loadparm context.

I was experimenting with pyparam / talloc and noticed the following behavior:

>>> talloc.report_full(a)
full talloc report on 'struct loadparm_context' (total    166 bytes in   5 blocks)
    /usr/local/etc/smb4.conf       contains     25 bytes in   1 blocks (ref 0) 0x800a49060
    passdb backend                 contains     15 bytes in   1 blocks (ref 0) 0x800a74f00
    passdb backend                 contains     15 bytes in   1 blocks (ref 0) 0x800a74020
    passbd backend                 contains     15 bytes in   1 blocks (ref 0) 0x800a730d0
>>> a.dump_a_parameter('passdb backend')
tdbsam
>>> talloc.report_full(a)
full talloc report on 'struct loadparm_context' (total    181 bytes in   6 blocks)
    passdb backend                 contains     15 bytes in   1 blocks (ref 0) 0x800a75440
    /usr/local/etc/smb4.conf       contains     25 bytes in   1 blocks (ref 0) 0x800a49060
    passdb backend                 contains     15 bytes in   1 blocks (ref 0) 0x800a74f00
    passdb backend                 contains     15 bytes in   1 blocks (ref 0) 0x800a74020
    passbd backend                 contains     15 bytes in   1 blocks (ref 0) 0x800a730d0

Obviously this is a minor issue because the get() method is probably more appropriate in most circumstances.

https://bugzilla.samba.org/show_bug.cgi?id=14544

Checklist

  • Commits have Signed-off-by: with name/author being identical to the commit author
  • (optional) This MR is just one part towards a larger feature.
  • (optional, if backport required) Bugzilla bug filed and BUG: tag added
  • Test suite updated with functionality tests
  • Test suite updated with negative tests
  • Documentation updated
  • CI timeout is 3h or higher (see Settings/CICD/General pipelines/ Timeout)

Reviewer's checklist:

  • There is a test suite reasonably covering new functionality or modifications
  • Function naming, parameters, return values, types, etc., are consistent and according to README.Coding.md
  • This feature/change has adequate documentation added
  • No obvious mistakes in the code

Merge request reports