Boost logo

Boost Users :

From: Robert Ramey (ramey_at_[hidden])
Date: 2007-06-27 18:01:10


My current copy the code includes in the file iserializer.hpp (line # 291)
the following code. Doesn't this address the situation?

Robert Ramey

template<class Archive, class T>
BOOST_DLLEXPORT void pointer_iserializer<Archive, T>::load_object_ptr(
    basic_iarchive & ar,
    void * & x,
    const unsigned int file_version
) const
{
    Archive & ar_impl = boost::smart_cast_reference<Archive &>(ar);
    auto_ptr_with_deleter<T> ap(heap_allocator<T>::invoke());
    if(NULL == ap.get())
    boost::throw_exception(std::bad_alloc()) ;
    T * t = ap.get();
    x = t;
    // catch exception during load_construct_data so that we don't
    // automatically delete the t which is most likely not fully
    // constructed
    BOOST_TRY {
        // this addresses an obscure situtation that occurs when
        // load_constructor de-serializes something through a pointer.
        ar.next_object_pointer(t);
        boost::serialization::load_construct_data_adl<Archive, T>(
            ar_impl,
            t,
            file_version
        );
    }
    BOOST_CATCH(...){
        ap.release();
    BOOST_RETHROW;
    }
    BOOST_CATCH_END
    ar_impl >> boost::serialization::make_nvp(NULL, * t);
    ap.release();
}

Johan Råde wrote:
> Robert Ramey wrote:
>> Johan Råde wrote:
>>> Maybe you could offer me a fix for the bug that makes the
>>> serialization library crash
>>> when you throw an exception in a load_construct_data function ;-)
>>
>> LOL - hmmm - I think I looked into this but I don't remember what
>> I did with it. Send me a link to the original complaint and I'll
>> check again.
>>
>> Robert Ramey
>
> The original complaint was in a private e-mail that I sent you 2 1/2
> years ago.
> I don't think I will be able to find it.
> The sender was rade_at_maths.lth.se.
> If you don't have the mail, I'd be happy to send you a short example
> that reproduces the bug.
>
> --Johan Råde


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net