Boost logo

Boost :

Subject: [boost] [serialization] Enum loading may lead to uninitialized value [Ask for change]
From: Andrey Upadyshev (oliora_at_[hidden])
Date: 2009-05-14 12:44:46


I found that template boost::archive::detail::load_enum_type
(boost\archive\detail\iserializer.hpp) may overvrite loading enum's
value with uninitialized ones. See comments:

template<class Archive, class T>
struct load_enum_type {
    static void invoke(Archive &ar, T &t){
        int i; // Initialize 'i' with trash
        ar >> boost::serialization::make_nvp(NULL, i); // Imagine: some
code in archive skips loading
        t = static_cast<T>(i); // Ooops, get the trash into 't'

I think it is more secure to initialize 'i' from 't'. So, if archive's
code skips loading, we just get 't' unchanged instead of corrupted.
Probably, someone can fix this in svn?

Andrey Upadyshev

P.S. Sorry for my English.

Boost list run by bdawes at, gregod at, cpdaniel at, john at