Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r62548 - trunk/boost/random
From: steven_at_[hidden]
Date: 2010-06-08 00:03:59


Author: steven_watanabe
Date: 2010-06-08 00:03:58 EDT (Tue, 08 Jun 2010)
New Revision: 62548
URL: http://svn.boost.org/trac/boost/changeset/62548

Log:
Check for range errors in the input operator of linear_congruential. Fixes #2667
Text files modified:
   trunk/boost/random/linear_congruential.hpp | 10 +++++++++-
   1 files changed, 9 insertions(+), 1 deletions(-)

Modified: trunk/boost/random/linear_congruential.hpp
==============================================================================
--- trunk/boost/random/linear_congruential.hpp (original)
+++ trunk/boost/random/linear_congruential.hpp 2010-06-08 00:03:58 EDT (Tue, 08 Jun 2010)
@@ -193,7 +193,15 @@
   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:


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk