return false if RandomGenerator fails init

pull/2/head
MITSUNARI Shigeo 6 years ago
parent e116eefe12
commit 0505ad5f0b
  1. 4
      include/cybozu/random_generator.hpp

@ -104,6 +104,10 @@ private:
template<class T> template<class T>
void read(bool *pb, T *buf, size_t bufNum) void read(bool *pb, T *buf, size_t bufNum)
{ {
if (fp_ == 0) {
*pb = false;
return;
}
const size_t byteSize = sizeof(T) * bufNum; const size_t byteSize = sizeof(T) * bufNum;
*pb = ::fread(buf, 1, (int)byteSize, fp_) == byteSize; *pb = ::fread(buf, 1, (int)byteSize, fp_) == byteSize;
} }

Loading…
Cancel
Save