mirror of
https://github.com/boostorg/random.git
synced 2026-01-19 04:22:17 +00:00
Check for range errors in the input operator of linear_congruential. Fixes #2667
[SVN r62548]
This commit is contained in:
@@ -193,7 +193,15 @@ public:
|
||||
operator>>(std::basic_istream<CharT,Traits>& is,
|
||||
linear_congruential& lcg)
|
||||
{
|
||||
return is >> lcg._x;
|
||||
IntType x;
|
||||
if(is >> x) {
|
||||
if(x >= (lcg.min)() && x <= (lcg.max)()) {
|
||||
lcg._x = x;
|
||||
} else {
|
||||
is.setstate(std::ios_base::failbit);
|
||||
}
|
||||
}
|
||||
return is;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user