]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit - gdb/ChangeLog
Fix a memory leak in py-param.c
authorTom Tromey <tom@tromey.com>
Wed, 20 Jun 2018 21:35:04 +0000 (15:35 -0600)
committerTom Tromey <tom@tromey.com>
Thu, 21 Jun 2018 03:10:10 +0000 (21:10 -0600)
commit0d0b0ea29af6abc0790d22f843a3d0cb09424a3a
tree1e8471fecfd1c30298679c7e45d1fd797c6b2af9
parent6ff79ccd1ca06a4c557ee81b73e0a535b9fd6001
Fix a memory leak in py-param.c

Mark Wielaard pointed out this memory leak to me:

    ==17633== 775 bytes in 1 blocks are definitely lost in loss record 13,346 of 13,967
    ==17633==    at 0x4C2DB6B: malloc (vg_replace_malloc.c:299)
    ==17633==    by 0x6652B7: xmalloc (common-utils.c:45)
    ==17633==    by 0xC4C889: xstrdup (xstrdup.c:34)
    ==17633==    by 0x5A71FD: unicode_to_encoded_string(_object*, char const*) (py-utils.c:81)
    ==17633==    by 0x5A73EB: python_string_to_host_string(_object*) (py-utils.c:158)
    ==17633==    by 0x59CC6C: get_doc_string(_object*, _object*) (py-param.c:334)
    ==17633==    by 0x59D2AA: parmpy_init(_object*, _object*, _object*) (py-param.c:728)

The bug here is that parmpy_init is written as though
add_setshow_generic takes ownership of its doc-string arguments.
However, it does not.  This patch fixes the bug in a straightforward
way and also applies some missing constification to make the problem
more apparent.

Tested on x86-64 Fedora 26.

gdb/ChangeLog
2018-06-20  Tom Tromey  <tom@tromey.com>

* python/py-param.c (add_setshow_generic): Make parameters const.
(parmpy_init): Update.
gdb/ChangeLog
gdb/python/py-param.c