[Boost-bugs] [Boost C++ Libraries] #3367: all wchar_t c-strings are truncated on deserialization

Subject: [Boost-bugs] [Boost C++ Libraries] #3367: all wchar_t c-strings are truncated on deserialization
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2009-08-26 16:45:04


#3367: all wchar_t c-strings are truncated on deserialization
--------------------------+-------------------------------------------------
 Reporter: anonymous | Owner: ramey
     Type: Bugs | Status: new
Milestone: Boost 1.40.0 | Component: serialization
  Version: Boost 1.39.0 | Severity: Problem
 Keywords: wchar_t |
--------------------------+-------------------------------------------------
 basic_binary_iprimitive<Archive, Elem, Tr>::load(wchar_t * ws)
 {
     std::size_t l;

     this->This()->load(l);

     load_binary(ws, l * sizeof(wchar_t) / sizeof(char));

     ws[l / sizeof(wchar_t)] = L'\0';
 }

 l is determined by std::wcslen on saving, which returns the number of
 wchar_t characters in the string. not the length in bytes.
 the \0 insert treats l as it was an offset in bytes.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/3367>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:01 UTC