Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r56738 - trunk/libs/serialization/src
From: ramey_at_[hidden]
Date: 2009-10-12 12:29:03


Author: ramey
Date: 2009-10-12 12:29:03 EDT (Mon, 12 Oct 2009)
New Revision: 56738
URL: http://svn.boost.org/trac/boost/changeset/56738

Log:
fix memory leaks
Text files modified:
   trunk/libs/serialization/src/void_cast.cpp | 35 ++++++++++++++++-------------------
   1 files changed, 16 insertions(+), 19 deletions(-)

Modified: trunk/libs/serialization/src/void_cast.cpp
==============================================================================
--- trunk/libs/serialization/src/void_cast.cpp (original)
+++ trunk/libs/serialization/src/void_cast.cpp 2009-10-12 12:29:03 EDT (Mon, 12 Oct 2009)
@@ -100,9 +100,10 @@
         extended_type_info const * derived,
         extended_type_info const * base,
         std::ptrdiff_t difference,
- bool includes_virtual_base
+ bool includes_virtual_base,
+ void_caster const * const parent
     ) :
- void_caster(derived, base, difference, true /*heap*/),
+ void_caster(derived, base, difference, parent),
         m_includes_virtual_base(includes_virtual_base)
     {
         recursive_register(includes_virtual_base);
@@ -211,18 +212,20 @@
                 (*it)->m_derived,
                 m_base,
                 m_difference + (*it)->m_difference,
- includes_virtual_base
+ includes_virtual_base,
+ this
             );
         if(* (*it)->m_derived == * m_base)
             new void_caster_shortcut(
                 m_derived,
                 (*it)->m_base,
                 m_difference + (*it)->m_difference,
- includes_virtual_base
+ includes_virtual_base,
+ this
             );
     }
 }
-
+
 BOOST_SERIALIZATION_DECL(void)
 void_caster::recursive_unregister() const {
     if(void_caster_registry::is_destroyed())
@@ -237,23 +240,17 @@
         if(
             m_base == (*it)->m_base
         && m_derived == (*it)->m_derived
- ||
- ! m_derived_observer.expired()
- && ! (*it)->m_base_observer.expired()
- && *m_derived == *(*it)->m_base
- ||
- ! m_base_observer.expired()
- && ! (*it)->m_derived_observer.expired()
- && *(*it)->m_derived == *m_base
         ){
+ s.erase(it++);
+ }
+ else
+ if( (*it)->m_parent == this ){
             // since recursion could invalidate it
+ // save pointer to set member
             const void_caster * vc = *it;
- s.erase(it);
- if(vc->m_heap){
- // save pointer to set member
- // and erase first
- delete vc;
- }
+ // and erase first
+ s.erase(it++);
+ delete vc;
             it = s.begin();
         }
         else


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk