summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Bauer <mail@ulrich-bauer.org>2019-12-10 17:17:11 +0100
committerUlrich Bauer <mail@ulrich-bauer.org>2019-12-10 17:17:11 +0100
commit47458eed67680f0beba78335b21748c1bfebeb76 (patch)
treef4e7f057b816ffa1ff9666385de32b2c438e949c
parent6a97e6c9e78a226abf4342d9b72bf1cc0235d775 (diff)
fix to read, properly handling premature end of file
-rw-r--r--ripser.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/ripser.cpp b/ripser.cpp
index 59bd8ac..5bc62bc 100644
--- a/ripser.cpp
+++ b/ripser.cpp
@@ -836,7 +836,7 @@ static const bool is_big_endian = *reinterpret_cast<const uint8_t*>(&endian_chec
template <typename T> T read(std::istream& input_stream) {
T result;
char* p = reinterpret_cast<char*>(&result);
- input_stream.read(p, sizeof(T));
+ if (input_stream.read(p, sizeof(T)) != sizeof(T) return T();
if (is_big_endian) std::reverse(p, p + sizeof(T));
return result;
}