summaryrefslogtreecommitdiff
path: root/files.cpp
diff options
context:
space:
mode:
authorTanzinul Islam <11808226+tanzislam@users.noreply.github.com>2020-09-20 01:41:35 +0100
committerGitHub <noreply@github.com>2020-09-19 20:41:35 -0400
commit0763b9984c6713d3d00de93de9854e58564493ea (patch)
tree9cb8c1e2d537ca6e6127d0da84a8422f4ce6602e /files.cpp
parent2ec97f4676068109350301e0db4c941e2b7e87a8 (diff)
downloadcryptopp-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.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/files.cpp b/files.cpp
index c200e9e7..2d05e03f 100644
--- a/files.cpp
+++ b/files.cpp
@@ -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;
}