From 4e0b99ca361319264ef4fca09eaeeaa9e99daa52 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Sun, 15 Sep 2019 15:01:33 -0400 Subject: [PATCH 1/1] sessiond: fix: memory leak of section name in elf parser MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit lttng_elf_get_section_name() returns a dynamically-allocated section name. However, lttng_elf_get_section_hdr_by_name() never frees this returned section name. Signed-off-by: Jérémie Galarneau --- src/common/lttng-elf.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/common/lttng-elf.c b/src/common/lttng-elf.c index b2aa88487..5d4b93bbb 100644 --- a/src/common/lttng-elf.c +++ b/src/common/lttng-elf.c @@ -605,6 +605,7 @@ int lttng_elf_get_section_hdr_by_name(struct lttng_elf *elf, char *curr_section_name; for (i = 0; i < elf->ehdr->e_shnum; ++i) { + bool name_equal; int ret = lttng_elf_get_section_hdr(elf, i, section_hdr); if (ret) { @@ -615,7 +616,9 @@ int lttng_elf_get_section_hdr_by_name(struct lttng_elf *elf, if (!curr_section_name) { continue; } - if (strcmp(curr_section_name, section_name) == 0) { + name_equal = strcmp(curr_section_name, section_name) == 0; + free(curr_section_name); + if (name_equal) { return 0; } } -- 2.34.1