Fix: potential leaks in error paths
[lttng-ust.git] / liblttng-ust / lttng-ust-elf.c
index 9186ee90cb7ab093a27b8eabcc03370076e5a3a8..4de380cf67d4edd803905e051ebde987bd90e683 100644 (file)
@@ -118,7 +118,7 @@ struct lttng_ust_elf_shdr *lttng_ust_elf_get_shdr(struct lttng_ust_elf *elf,
        }
 
        offset = (off_t) elf->ehdr->e_shoff
-               + (off_t) index * elf->ehdr->e_shentsize;
+                       + (off_t) index * elf->ehdr->e_shentsize;
        if (lseek(elf->fd, offset, SEEK_SET) < 0) {
                goto error;
        }
@@ -478,6 +478,7 @@ int lttng_ust_elf_get_build_id_from_segment(
        *found = _found;
        return 0;
 error:
+       free(_build_id);
        return -1;
 }
 
@@ -544,6 +545,7 @@ int lttng_ust_elf_get_build_id(struct lttng_ust_elf *elf, uint8_t **build_id,
        *found = _found;
        return 0;
 error:
+       free(_build_id);
        return -1;
 }
 
@@ -624,10 +626,8 @@ end:
        return 0;
 
 error:
-       if (section_name) {
-               free(section_name);
-       }
-
+       free(_filename);
+       free(section_name);
        return -1;
 }
 
@@ -682,5 +682,6 @@ int lttng_ust_elf_get_debug_link(struct lttng_ust_elf *elf, char **filename,
        *found = _found;
        return 0;
 error:
+       free(_filename);
        return -1;
 }
This page took 0.026777 seconds and 4 git commands to generate.