Fix: elf: leaks on error paths
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 4 Sep 2015 06:00:09 +0000 (02:00 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 4 Sep 2015 06:00:53 +0000 (02:00 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
liblttng-ust-dl/lttng-ust-dl.c
liblttng-ust/lttng-ust-elf.c

index d6b807149861415e30212a5ca72100dfef8db4c7..d6abeff0820e024d1a6512213df5c8ec6a5e539f 100644 (file)
@@ -70,9 +70,9 @@ void lttng_ust_dl_dlopen(void *so_base, const char *so_name, void *ip)
        char resolved_path[PATH_MAX];
        struct lttng_ust_elf *elf;
        uint64_t memsz;
-       uint8_t *build_id;
+       uint8_t *build_id = NULL;
        size_t build_id_len;
-       char *dbg_file;
+       char *dbg_file = NULL;
        uint32_t crc;
        int has_build_id = 0, has_debug_link = 0;
        int ret;
@@ -119,6 +119,8 @@ void lttng_ust_dl_dlopen(void *so_base, const char *so_name, void *ip)
        }
 
 end:
+       free(dbg_file);
+       free(build_id);
        lttng_ust_elf_destroy(elf);
        return;
 }
index 026d65cec362ce757994d2d500a295d6839ba44b..ce58539e67880e853224a862c6aaed3ca6094b7a 100644 (file)
@@ -478,6 +478,7 @@ int lttng_ust_elf_get_build_id_from_segment(
        *found = _found;
        return 0;
 error:
+       free(_build_id);
        return -1;
 }
 
@@ -624,10 +625,8 @@ end:
        return 0;
 
 error:
-       if (section_name) {
-               free(section_name);
-       }
-
+       free(_filename);
+       free(section_name);
        return -1;
 }
 
This page took 0.026373 seconds and 5 git commands to generate.