diff --git a/include/cybozu/random_generator.hpp b/include/cybozu/random_generator.hpp index 4a9f071..2e097e3 100644 --- a/include/cybozu/random_generator.hpp +++ b/include/cybozu/random_generator.hpp @@ -104,6 +104,10 @@ private: template void read(bool *pb, T *buf, size_t bufNum) { + if (fp_ == 0) { + *pb = false; + return; + } const size_t byteSize = sizeof(T) * bufNum; *pb = ::fread(buf, 1, (int)byteSize, fp_) == byteSize; }