* archive.cc (include_member): Destroy Read_symbols_data object before
authorCary Coutant <ccoutant@google.com>
Wed, 7 Apr 2010 22:58:23 +0000 (22:58 +0000)
committerCary Coutant <ccoutant@google.com>
Wed, 7 Apr 2010 22:58:23 +0000 (22:58 +0000)
releasing file.
* object.cc (Read_symbols_data::~Read_symbols_data) New destructor.
* object.h (Read_symbols_data::Read_symbols_data) New constructor.
(Read_symbols_data::~Read_symbols_data) New destructor.
(Section_relocs::Section_relocs) New constructor.
(Section_relocs::~Section_relocs) New destructor.
(Read_relocs_data::Read_relocs_data) New constructor.
(Read_relocs_data::~Read_relocs_data) New destructor.
* testsuite/binary_unittest.cc (Sized_binary_test): Set sd member
pointers to NULL after deleting.

gold/ChangeLog
gold/archive.cc
gold/object.cc
gold/object.h
gold/testsuite/binary_unittest.cc

index e1e126abf6d273090e7eff6d56ece6c1fea69b76..524340d3418e76a60b76a059b4f59e27f60aebab 100644 (file)
@@ -1,3 +1,17 @@
+2010-04-07  Cary Coutant  <ccoutant@google.com>
+
+       * archive.cc (include_member): Destroy Read_symbols_data object before
+       releasing file.
+       * object.cc (Read_symbols_data::~Read_symbols_data) New destructor.
+       * object.h (Read_symbols_data::Read_symbols_data) New constructor.
+       (Read_symbols_data::~Read_symbols_data) New destructor.
+       (Section_relocs::Section_relocs) New constructor.
+       (Section_relocs::~Section_relocs) New destructor.
+       (Read_relocs_data::Read_relocs_data) New constructor.
+       (Read_relocs_data::~Read_relocs_data) New destructor.
+       * testsuite/binary_unittest.cc (Sized_binary_test): Set sd member
+       pointers to NULL after deleting.
+
 2010-04-07  Doug Kwan  <dougkwan@google.com>
 
        * arm.cc: Replace "endianity" with "endianness" in comments.
index c62fb247b9bf548cefef991c74f79d1330ded078..36e4862871e28e105b27b4eca97d1ddb0e03490a 100644 (file)
@@ -877,10 +877,12 @@ Archive::include_member(Symbol_table* symtab, Layout* layout,
     delete obj;
   else
     {
-      Read_symbols_data sd;
-      obj->read_symbols(&sd);
-      obj->layout(symtab, layout, &sd);
-      obj->add_symbols(symtab, &sd, layout);
+      {
+       Read_symbols_data sd;
+       obj->read_symbols(&sd);
+       obj->layout(symtab, layout, &sd);
+       obj->add_symbols(symtab, &sd, layout);
+      }
 
       // If this is an external member of a thin archive, unlock the file
       // for the next task.
index b9d00280cec05733a198d80a4658047ab97347aa..8751d550f1f2845fa8dfa001ffc8951aa94754bd 100644 (file)
 namespace gold
 {
 
+// Struct Read_symbols_data.
+
+// Destroy any remaining File_view objects.
+
+Read_symbols_data::~Read_symbols_data()
+{
+  if (this->section_headers != NULL)
+    delete this->section_headers;
+  if (this->section_names != NULL)
+    delete this->section_names;
+  if (this->symbols != NULL)
+    delete this->symbols;
+  if (this->symbol_names != NULL)
+    delete this->symbol_names;
+  if (this->versym != NULL)
+    delete this->versym;
+  if (this->verdef != NULL)
+    delete this->verdef;
+  if (this->verneed != NULL)
+    delete this->verneed;
+}
+
 // Class Xindex.
 
 // Initialize the symtab_xindex_ array.  Find the SHT_SYMTAB_SHNDX
index dc0cb2d71d563c0f424e69d6a479c30eb8064059..02747a7caa6f277d78cd4b79c773afe749a9ce39 100644 (file)
@@ -55,6 +55,13 @@ class Stringpool_template;
 
 struct Read_symbols_data
 {
+  Read_symbols_data()
+    : section_headers(NULL), section_names(NULL), symbols(NULL),
+      symbol_names(NULL), versym(NULL), verdef(NULL), verneed(NULL)
+  { }
+
+  ~Read_symbols_data();
+
   // Section headers.
   File_view* section_headers;
   // Section names.
@@ -102,6 +109,13 @@ struct Symbol_location_info
 
 struct Section_relocs
 {
+  Section_relocs()
+    : contents(NULL)
+  { }
+
+  ~Section_relocs()
+  { delete this->contents; }
+
   // Index of reloc section.
   unsigned int reloc_shndx;
   // Index of section that relocs apply to.
@@ -125,6 +139,13 @@ struct Section_relocs
 
 struct Read_relocs_data
 {
+  Read_relocs_data()
+    : local_symbols(NULL)
+  { }
+
+  ~Read_relocs_data()
+  { delete this->local_symbols; }
+
   typedef std::vector<Section_relocs> Relocs_list;
   // The relocations.
   Relocs_list relocs;
index b2e14df645f1ea0d109347e6ee250ca0e108560f..8e950620c94b32da00ff6547e822626eae5f256e 100644 (file)
@@ -87,9 +87,13 @@ Sized_binary_test()
   Read_symbols_data sd;
   object->read_symbols(&sd);
   delete sd.section_headers;
+  sd.section_headers = NULL;
   delete sd.section_names;
+  sd.section_names = NULL;
   delete sd.symbols;
+  sd.symbols = NULL;
   delete sd.symbol_names;
+  sd.symbol_names = NULL;
 
   Sized_relobj<size, big_endian>* relobj =
     static_cast<Sized_relobj<size, big_endian>*>(object);
This page took 0.03574 seconds and 4 git commands to generate.