From: Jérémie Galarneau Date: Sun, 15 Sep 2019 19:01:33 +0000 (-0400) Subject: sessiond: fix: memory leak of section name in elf parser X-Git-Tag: v2.12.0-rc1~374 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=4e0b99ca361319264ef4fca09eaeeaa9e99daa52;p=lttng-tools.git sessiond: fix: memory leak of section name in elf parser 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 --- 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; } }