summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitaliy Cherepanov <v.cherepanov@samsung.com>2015-10-06 14:59:52 +0300
committerVitaliy Cherepanov <v.cherepanov@samsung.com>2015-10-06 14:59:52 +0300
commitc16dbc189e51fb9c95abc35d692d24757d61adab (patch)
tree8fd4b96b29949b76b1234c9833a353fb5307a34d
parent3fcaa6571c506614e124e0e6a7987a987088158a (diff)
downloadswap-probe-c16dbc189e51fb9c95abc35d692d24757d61adab.tar.gz
swap-probe-c16dbc189e51fb9c95abc35d692d24757d61adab.tar.bz2
swap-probe-c16dbc189e51fb9c95abc35d692d24757d61adab.zip
[FIX] prevent issues
----------------------------------------------------------- | CID | Type | File | Function | |---------------------------------------------------------| | 41294 | resource leak | lib_parse_elf.c | get_plt_addrs | |---------------------------------------------------------| Change-Id: I2092a963b75ba5280cef6ac801d41c1e34866454 Signed-off-by: Vitaliy Cherepanov <v.cherepanov@samsung.com>
-rw-r--r--elf_parsing/lib_parse_elf.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/elf_parsing/lib_parse_elf.c b/elf_parsing/lib_parse_elf.c
index 28ab17b..ba266aa 100644
--- a/elf_parsing/lib_parse_elf.c
+++ b/elf_parsing/lib_parse_elf.c
@@ -16,6 +16,7 @@ enum {
ELF_PARSE_INVALID_CLASS,
ELF_PARSE_MMAP_ERROR,
ELF_PARSE_MUNMAP_ERROR,
+ ELF_PARSE_UNKNOWN_ERROR,
ELF_PARSE_NO_MEM
};
@@ -487,8 +488,12 @@ int get_plt_addrs(const char *filename, const char **names, size_t n, Elf_Addr *
goto get_plt_fail;
}
- if (!__do_get_plt_addrs(elf, names, addrs, n))
- *addrs_p = addrs;
+ if (__do_get_plt_addrs(elf, names, addrs, n) != 0) {
+ ret = ELF_PARSE_UNKNOWN_ERROR;
+ goto free_data;
+ }
+
+ *addrs_p = addrs;
ret = munmap_file(elf, &elf_len);
@@ -498,7 +503,9 @@ int get_plt_addrs(const char *filename, const char **names, size_t n, Elf_Addr *
}
return ret;
-
+free_data:
+ free(addrs);
+ *addrs_p = NULL;
get_plt_fail:
/* ignore unmap error */
munmap_file(elf, &elf_len);