diff options
author | Tanzinul Islam <11808226+tanzislam@users.noreply.github.com> | 2020-09-20 01:41:35 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-19 20:41:35 -0400 |
commit | 0763b9984c6713d3d00de93de9854e58564493ea (patch) | |
tree | 9cb8c1e2d537ca6e6127d0da84a8422f4ce6602e /files.cpp | |
parent | 2ec97f4676068109350301e0db4c941e2b7e87a8 (diff) | |
download | cryptopp-git-0763b9984c6713d3d00de93de9854e58564493ea.tar.gz |
Clear failbit after failed istream::seekg() (#968)
`std::istream` does not generally need to support seek-to-end behavior; it depends on the underlying `std::streambuf` implementation. If it fails the stream will set `failbit`, after which any further operation would fail until it is cleared.
Reference:
- https://en.cppreference.com/w/cpp/io/basic_istream/seekg
- https://en.cppreference.com/w/cpp/io/basic_streambuf/pubseekoff
This issue surfaced in my use case after 04dee2a46, as I am using several `std::streambuf`-derived classes as streaming codecs and they do not support a seek-to-end functionality.
Diffstat (limited to 'files.cpp')
-rw-r--r-- | files.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -67,6 +67,7 @@ lword FileStore::MaxRetrievable() const std::streampos current = m_stream->tellg();
std::streampos end = m_stream->seekg(0, std::ios::end).tellg();
+ m_stream->clear();
m_stream->seekg(current);
return end-current;
}
|