From: Petr Machata Date: Mon, 30 Nov 2009 06:46:12 +0000 (+0100) Subject: dwarflint: Plug a leak X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d99dbc93f9a5aa5e3e8ad4ab6104711a278306c7;p=thirdparty%2Felfutils.git dwarflint: Plug a leak --- diff --git a/src/dwarflint/checks-low.cc b/src/dwarflint/checks-low.cc index 919cd94a9..3db0b52dc 100644 --- a/src/dwarflint/checks-low.cc +++ b/src/dwarflint/checks-low.cc @@ -192,7 +192,7 @@ layout_rel_file (Elf *elf) return elf; } - Elf * + bool elf_file_init (struct elf_file *file, int fd) { Elf *elf = open_elf (fd); @@ -372,7 +372,7 @@ layout_rel_file (Elf *elf) << std::endl; } - return elf; + return true; close_and_out: if (elf != NULL) @@ -385,13 +385,14 @@ layout_rel_file (Elf *elf) << "error while closing Elf descriptor: " << elf_errmsg (err) << std::endl; } - return NULL; + return false; } } load_sections::load_sections (dwarflint &lint) { - elf_file_init (&file, lint.fd ()); + if (!elf_file_init (&file, lint.fd ())) + throw check_base::failed (); } load_sections::~load_sections () @@ -399,6 +400,7 @@ load_sections::~load_sections () if (file.ebl != NULL) ebl_closebackend (file.ebl); free (file.sec); + elf_end (file.elf); } namespace diff --git a/src/dwarflint/checks-low.hh b/src/dwarflint/checks-low.hh index f93c57af4..de6510765 100644 --- a/src/dwarflint/checks-low.hh +++ b/src/dwarflint/checks-low.hh @@ -109,7 +109,6 @@ public: std::vector cus; explicit check_debug_info (dwarflint &lint); - ~check_debug_info (); }; static reg reg_debug_info;