sessiond: fix: memory leak of section name in elf parser
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 15 Sep 2019 19:01:33 +0000 (15:01 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 15 Sep 2019 19:03:03 +0000 (15:03 -0400)
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 <jeremie.galarneau@efficios.com>
src/common/lttng-elf.c

index b2aa88487e1dff286c21d0442f6cdf175a68681f..5d4b93bbb80d13943571fede84f82057dea3a09d 100644 (file)
@@ -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;
                }
        }
This page took 0.026075 seconds and 4 git commands to generate.