X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=lib%2Fbin-info.c;h=e5d515005125510e0537603e05d299aac904839c;hp=14b0dea3de1caf822844e1d80e456104fe7f4390;hb=5f38bc819a3feece3f0c8cf1155735b090e533c1;hpb=fcd94e371dff29222e2de06a12b9e576845a963e diff --git a/lib/bin-info.c b/lib/bin-info.c index 14b0dea3..e5d51500 100644 --- a/lib/bin-info.c +++ b/lib/bin-info.c @@ -266,8 +266,7 @@ int bin_info_set_dwarf_info_build_id(struct bin_info *bin) dbg_dir = opt_debug_info_dir ? : DEFAULT_DEBUG_DIR; - /* 2 characters per byte printed in hex, +1 for '/' and +1 for - * '\0' */ + /* 2 characters per byte printed in hex, +1 for '/' and +1 for '\0' */ build_id_file_len = (2 * bin->build_id_len) + 1 + strlen(BUILD_ID_SUFFIX) + 1; build_id_file = malloc(build_id_file_len); @@ -483,7 +482,7 @@ end: static int bin_info_set_elf_file(struct bin_info *bin) { - int elf_fd; + int elf_fd = -1; Elf *elf_file = NULL; if (!bin) { @@ -513,12 +512,13 @@ int bin_info_set_elf_file(struct bin_info *bin) return 0; error: - close(elf_fd); + if (elf_fd >= 0) { + close(elf_fd); + } elf_end(elf_file); return -1; } - BT_HIDDEN void source_location_destroy(struct source_location *src_loc) { @@ -529,6 +529,7 @@ void source_location_destroy(struct source_location *src_loc) free(src_loc->filename); g_free(src_loc); } + /** * Append a string representation of an address offset to an existing * string.