From: Petr Machata Date: Mon, 9 Nov 2009 07:50:43 +0000 (+0100) Subject: dwarflint: Fix memory errors in pri::pribase X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f9e426bf97c69594a3e953e4597ece46b319bcfc;p=thirdparty%2Felfutils.git dwarflint: Fix memory errors in pri::pribase --- diff --git a/src/dwarflint/pri.cc b/src/dwarflint/pri.cc index e0afa5791..741b7a2ab 100644 --- a/src/dwarflint/pri.cc +++ b/src/dwarflint/pri.cc @@ -2,6 +2,12 @@ #include "pri.hh" #include +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) { diff --git a/src/dwarflint/pri.hh b/src/dwarflint/pri.hh index 3998563fc..5e49e0213 100644 --- a/src/dwarflint/pri.hh +++ b/src/dwarflint/pri.hh @@ -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); };