Opened 15 years ago

Closed 15 years ago

#969 closed Bugs (fixed)

basic_binary_iprimitive::load_binary bug

Reported by: anonymous Owned by: Robert Ramey
Milestone: Component: serialization
Version: Severity: Problem
Keywords: Cc:

Description

boost\archive\basic_binary_iprimitive.hpp, line 163, line 174. Now code:

   if(count != static_cast<std::size_t>(s))
...
       if(count != 1)

Need:

   if(scount != static_cast<std::size_t>(s))
...
       if(scount != 1)

Change History (3)

comment:1 by Dave Abrahams, 15 years ago

Owner: set to Robert Ramey

comment:2 by Marvin Sielenkemper <Marvin.Sielenkemper@…>, 15 years ago

There is another bug in this function that causes the test

  void BoostBinaryWArchiveBug()
  {
    const std::string srcValue("12345");
    std::string dstValue;

    std::wostringstream os;
    boost::archive::binary_woarchive(os) << srcValue;

    std::wistringstream is(os.str());
    boost::archive::binary_wiarchive(is) >> dstValue;

    BOOST_CHECK_EQUAL(srcValue, dstValue);
  }

to fail with the error message

error in "BoostBinaryWArchiveBug": check srcValue == dstValue failed [12345 != 5234]

I found that bug in version 1.33.1, but the problem seems to still be present in 1.34.1. The bug is fixed by changing the memcpy-line from

        std::memcpy(address, &t, s);

to

        std::memcpy(static_cast<char*>(address) + (count - s), &t, s);

comment:3 by Robert Ramey, 15 years ago

Resolution: fixed
Severity: ShowstopperProblem
Status: newclosed

I'll put this in.

Note: See TracTickets for help on using tickets.