]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
dwarflint: Fix memory errors in pri::pribase
authorPetr Machata <pmachata@redhat.com>
Mon, 9 Nov 2009 07:50:43 +0000 (08:50 +0100)
committerPetr Machata <pmachata@redhat.com>
Wed, 18 Aug 2010 12:55:13 +0000 (14:55 +0200)
src/dwarflint/pri.cc
src/dwarflint/pri.hh

index e0afa5791a10ffaabfa502b321caf63cff64a4ce..741b7a2ab5a4bf64c7456a28d2d59ca988a8262d 100644 (file)
@@ -2,6 +2,12 @@
 #include "pri.hh"
 #include <sstream>
 
+std::ostream &
+pri::operator << (std::ostream &os, pri::pribase const &obj)
+{
+  return os << obj.m_s;
+}
+
 pri::attr::attr (int attr_name)
   : pribase (dwarf_attr_string (attr_name))
 {}
@@ -14,12 +20,6 @@ pri::tag::tag (int die_tag)
   : pribase (dwarf_tag_string (die_tag))
 {}
 
-std::ostream &
-pri::operator << (std::ostream &os, pri::pribase const &obj)
-{
-  return os << obj.m_a << obj.m_b << obj.m_c;
-}
-
 std::ostream &
 pri::operator << (std::ostream &os, pri::ref const &obj)
 {
index 3998563fc6e4e4343949807c4647619a640e36ed..5e49e02135640bb4114126d62191beb0bfd5a238 100644 (file)
@@ -8,15 +8,13 @@ namespace pri
 {
   class pribase
   {
-    std::string const &m_a;
-    std::string const &m_b;
-    std::string const &m_c;
+    std::string m_s;
 
   protected:
     pribase (std::string const &a,
             std::string const &b = "",
             std::string const &c = "")
-      : m_a (a), m_b (b), m_c (c)
+      : m_s (a + b + c)
     {}
     friend std::ostream &operator << (std::ostream &os, pribase const &obj);
   };