]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
dwarflint: Plug a leak
authorPetr Machata <pmachata@redhat.com>
Mon, 30 Nov 2009 06:46:12 +0000 (07:46 +0100)
committerPetr Machata <pmachata@redhat.com>
Wed, 18 Aug 2010 12:55:14 +0000 (14:55 +0200)
src/dwarflint/checks-low.cc
src/dwarflint/checks-low.hh

index 919cd94a9429de549aa03d379395a85073182959..3db0b52dc59398ad552cf4c948f0393e1649a745 100644 (file)
@@ -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
index f93c57af42a8e5ec17053dd3a158572938fa49b7..de65107659eb5a9f76f3f8de7a51e0258e6fc572 100644 (file)
@@ -109,7 +109,6 @@ public:
   std::vector<cu> cus;
 
   explicit check_debug_info (dwarflint &lint);
-  ~check_debug_info ();
 };
 static reg<check_debug_info> reg_debug_info;