serialisation::archive - no test for eof after reading from istream?!

Hello, I don't know why in basic_test_iprimitive::load the stream isn't tested for eof or fail after reading from it? In my case I get a string-resize-exception thrown because it is not tested for eof or fail after 'is >> t' (text_iarchive_impl.ipp line 48; size is not initialized and contains a to huge number which causes a resize exception on line 55). This was raised from the stream which was connected to a socket. The peer has closed the socket and the read operation on the socket has returned EOF.

Oliver.Kowalke@infineon.com wrote:
Hello, I don't know why in basic_test_iprimitive::load the stream isn't tested for eof or fail after reading from it?
because archives should never read beyond the end of the stream. The current version does this but this is an oversight which will be correctedin the next release.
In my case I get a string-resize-exception thrown because it is not tested for eof or fail after 'is >> t' (text_iarchive_impl.ipp line 48; size is not initialized and contains a to huge number which causes a resize exception on line 55).
This was raised from the stream which was connected to a socket. The peer has closed the socket and the read operation on the socket has returned EOF.
The fix is in test_oarchive_impl.ipp which will invoke os << std::endl when the archive is closed. This should be sufficient that the stream is never read beyond EOF. Robert Ramey
participants (2)
-
Oliver.Kowalke@infineon.com
-
Robert Ramey