aboutsummaryrefslogtreecommitdiff
path: root/gdb/cli/cli-script.c
diff options
context:
space:
mode:
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>2022-11-27 19:20:58 +0100
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>2022-11-27 21:08:24 +0100
commitc801f8f138c03cde994db597d11953c21ed892de (patch)
tree3406d68b0b6f1a01f997c6b7e4cef60d30099410 /gdb/cli/cli-script.c
parent30220b46d4cc34f4882525eb92b40725637cbba7 (diff)
downloadgdb-c801f8f138c03cde994db597d11953c21ed892de.zip
gdb-c801f8f138c03cde994db597d11953c21ed892de.tar.gz
gdb-c801f8f138c03cde994db597d11953c21ed892de.tar.bz2
fix leak in gdb_environ
valgrind reports a leak when assigning a gdb_environ to another gdb_environ. The memory allocated for the target gdb_environ env variables is not released. The gdb_environ selftest reproduces the leak (see below). Fix the leak by clearing the target gdb_environ before std::move-ing the members. Tested natively and re-running all tests under valgrind. ==3261873== 4,842 bytes in 69 blocks are definitely lost in loss record 6,772 of 6,839 ==3261873== at 0x483979B: malloc (vg_replace_malloc.c:393) ==3261873== by 0x25A454: xmalloc (alloc.c:57) ==3261873== by 0x7D1E4E: xstrdup (xstrdup.c:34) ==3261873== by 0x7E2A51: gdb_environ::from_host_environ() (environ.cc:56) ==3261873== by 0x66F1C8: test_reinit_from_host_environ (environ-selftests.c:78) ==3261873== by 0x66F1C8: selftests::gdb_environ_tests::run_tests() (environ-selftests.c:285) ==3261873== by 0x7EFC43: operator() (std_function.h:622) = Approved-By: Simon Marchi <simon.marchi@efficios.com>
Diffstat (limited to 'gdb/cli/cli-script.c')
0 files changed, 0 insertions, 0 deletions