Changeset 54821


Ignore:
Timestamp:
Jul 8, 2009, 10:55:36 PM (9 years ago)
Author:
Robert Ramey
Message:

Fix invalid pointer in unregister cast in void_cast.cpp

Location:
trunk/libs/serialization/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/libs/serialization/src/extended_type_info.cpp

    r54754 r54821  
    7373        return false;
    7474    };
     75    virtual bool &
     76    get_is_destroyed() const {
     77        static bool dummy = true;
     78        assert(false);
     79        return dummy;
     80    }
     81
    7582public:
    7683    extended_type_info_arg(const char * key) :
  • trunk/libs/serialization/src/extended_type_info_typeid.cpp

    r53141 r54821  
    107107{
    108108private:
     109    virtual bool &
     110    get_is_destroyed() const {
     111        static bool dummy = false;
     112        assert(false);
     113        return dummy;
     114    }
    109115public:
    110116    extended_type_info_typeid_arg(const std::type_info & ti){
  • trunk/libs/serialization/src/void_cast.cpp

    r54754 r54821  
    223223    // delete all shortcuts which use this primitive
    224224    void_cast_detail::set_type::iterator it;
    225     for(it = s.begin(); it != s.end(); ++it){
    226         if((*it)->is_shortcut()){
    227             if(m_derived == (*it)->m_base
    228             || (*it)->m_derived == m_base){
     225    for(it = s.begin(); it != s.end();){
     226        // note item 9 from Effective STL !!!
     227        if((*it)->m_base == m_base && m_derived == (*it)->m_derived
     228        && (
     229               (*it)->m_base_is_destroyed
     230            || (*it)->m_derived_is_destroyed
     231            || *m_derived == *(*it)->m_base
     232            || *(*it)->m_derived == *m_base
     233        )){
     234            // since recursion could invalidate it
     235            const void_caster * vc = *it;
     236            s.erase(it++);
     237            if(vc->is_shortcut()){
    229238                // save pointer to set member
    230                 const void_caster * vc = *it;
    231239                // and erase first
    232                 s.erase(it);
    233                 // since recursion could invalidate it
    234240                delete vc;
    235                 it = s.begin();
    236241            }
    237242        }
     243        else
     244            it++;
    238245    }   
    239 
    240     const void_cast_detail::void_caster_argument ca(m_derived, m_base);
    241     it = s.find(& ca);
    242     if(s.end() == it)
    243         return;
    244 
    245     s.erase(it);
    246246}
    247247
Note: See TracChangeset for help on using the changeset viewer.